Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Monad transformers and MonadPlus (Brent Yorgey)
   2. Re:  Monad transformers and MonadPlus (Daniel Fischer)
   3.  (no subject) (Hongchao Liu)
   4.  Announcement: Real World Haskell - Reading Group (Jeff Greer)
   5. Re:  (no subject) (Henk-Jan van Tuyl)
   6.  Re: Announcement: Real World Haskell - Reading   Group (Gour D.)
   7.  Foreign function interface? (s...@pobox.com)
   8.  edit-dist (Andy Larocque)


----------------------------------------------------------------------

Message: 1
Date: Fri, 30 Jul 2010 18:23:00 +0100
From: Brent Yorgey <byor...@seas.upenn.edu>
Subject: Re: [Haskell-beginners] Monad transformers and MonadPlus
To: beginners@haskell.org
Message-ID: <20100730172300.ga22...@seas.upenn.edu>
Content-Type: text/plain; charset=us-ascii

On Fri, Jul 30, 2010 at 02:48:17PM +0200, Daniel Fischer wrote:
> On Friday 30 July 2010 13:56:44, Antoine Latter wrote:
> > You could always add a MondPlus instance to IO directly (or a newtype
> > wrapper).
> >
> > 'mplus' would set up exception handling and 'mzero' would through an
> > exception. You might want to limit it to a subset of exceptions, though.
> 
> Once upon a time, there was a MonadPlus instance for IO.
> However, one of the laws a MonadPlus instance should satisfy is
> 
> m >> mzero === mzero
> 
> You can't have that in IO, since there's no unPutStrLn and such.
> Therefore, the MonadPlus instance for IO was removed.

If I understand correctly, however, there is some debate over what the
"correct" laws for MonadPlus ought to be.  One can also imagine other
useful monads which satisfy other MonadPlus laws but not the one
above, such as MaybeT (State Int), in which failure short-circuits any
future modifications to the state, but does not roll back any state
modifications that may have happened up to the point of failure.

-Brent 


------------------------------

Message: 2
Date: Fri, 30 Jul 2010 20:01:55 +0200
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] Monad transformers and MonadPlus
To: beginners@haskell.org
Message-ID: <201007302001.56014.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="iso-8859-1"

On Friday 30 July 2010 19:23:00, Brent Yorgey wrote:
>
> If I understand correctly, however, there is some debate over what the
> "correct" laws for MonadPlus ought to be.

Yes, and the haskellwiki page on MonadPlus doesn't even mention the 'right 
zero' property (but the Control.Monad haddocks do).

> One can also imagine other
> useful monads which satisfy other MonadPlus laws but not the one
> above, such as MaybeT (State Int), in which failure short-circuits any
> future modifications to the state, but does not roll back any state
> modifications that may have happened up to the point of failure.
>
> -Brent

Yep, there are several useful variants possible. That is probably why 
there's no final agreement on the laws.



------------------------------

Message: 3
Date: Fri, 30 Jul 2010 19:07:29 +0100
From: Hongchao Liu <lbs....@gmail.com>
Subject: [Haskell-beginners] (no subject)
To: "beginners@haskell.org" <beginners@haskell.org>
Message-ID:
        <aanlktinfenexesafyaafftkd3d1rltnibs7nc8ra1...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

-- 
Best wishes,
Hongchao

Character is the virtue of hard times.


------------------------------

Message: 4
Date: Fri, 30 Jul 2010 14:18:56 -0500
From: Jeff Greer <jgreer...@gmail.com>
Subject: [Haskell-beginners] Announcement: Real World Haskell -
        Reading Group
To: beginners@haskell.org
Message-ID:
        <aanlkti=uzad=wzb+mjdrvhohpsdurrt7_ccmxs0ld...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

We are organizing a reading group for O'Reilly's - Real World Haskell

We will start with Chapter 1 on August 8, 2010 and then cover additional
chapters at two week intervals.

If interested: http://linuxagora.com

This is an all volunteer web site - no advertising, no fees

Thank you,
Jeff
-- 
http://linuxagora.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100730/ee297e8f/attachment-0001.html

------------------------------

Message: 5
Date: Fri, 30 Jul 2010 21:46:14 +0200
From: "Henk-Jan van Tuyl" <hjgt...@chello.nl>
Subject: Re: [Haskell-beginners] (no subject)
To: "beginners@haskell.org" <beginners@haskell.org>,    "Hongchao Liu"
        <lbs....@gmail.com>
Message-ID: <op.vgn87cc1pz0...@zen5.router.home>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Fri, 30 Jul 2010 20:07:29 +0200, Hongchao Liu <lbs....@gmail.com> wrote:

> Best wishes,
> Hongchao

Thanks

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--


------------------------------

Message: 6
Date: Fri, 30 Jul 2010 22:18:04 +0200
From: "Gour D." <g...@atmarama.net>
Subject: [Haskell-beginners] Re: Announcement: Real World Haskell -
        Reading Group
To: beginners@haskell.org
Message-ID: <20100730221804.43b9c...@gaura-nitai.no-ip.org>
Content-Type: text/plain; charset="us-ascii"

On Fri, 30 Jul 2010 14:18:56 -0500
>>>>>> "Jeff" == Jeff Greer <jgreer...@gmail.com> wrote:

Jeff> We are organizing a reading group for O'Reilly's - Real World
Jeff> Haskell

Cool. Nice opportunity to (finally) learn it.

Jeff> We will start with Chapter 1 on August 8, 2010 and then cover
Jeff> additional chapters at two week intervals.

Hmmm...28 chapters ---> ~14 months :-)


Sincerely,
Gour

-- 

Gour  | Hlapicina, Croatia  | GPG key: CDBF17CA
----------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20100730/560099db/signature-0001.bin

------------------------------

Message: 7
Date: Fri, 30 Jul 2010 15:42:41 -0500
From: s...@pobox.com
Subject: [Haskell-beginners] Foreign function interface?
To: beginners@haskell.org
Message-ID: <19539.14657.437123.834...@montanaro.dyndns.org>
Content-Type: text/plain; charset=us-ascii


Still just doinking around with Haskell, trying to get a feel for it.  (It
still looks pretty obscure to me so far.)

I see that Haskell has a foreign function interface and a preprocessor to
help generate.  I normally work in Python, so am familiar with its concept
of extension modules (C code written using Python's C API to go back and
forth between Python and underlying C library code), tools to automate that
like SWIG and Boost.Python, and Python's ctypes module which uses libffi.

What of these tools does Haskell's foreign function interface most closely
resemble?  Can it interface with C++ as well as C?

Thx,

-- 
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/


------------------------------

Message: 8
Date: Fri, 30 Jul 2010 16:45:02 -0400
From: Andy Larocque <abla...@gmail.com>
Subject: [Haskell-beginners] edit-dist
To: beginners@haskell.org
Message-ID:
        <aanlktiknnftewc-uux7w3qfxecnod337q63tg7vfr...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

I am a senior who used to do a lot of programming in imperative
languages, and now am new at learning this functional approach.
I have been experimenting with one of Simon Thompson's examples from
his book "The Craft 2e.." ; the edit-distance problem,
and have some questions below I would really appreciate answers to.
Here is the code from his book --

-- A type to represent the different sorts of Edit operations.
data Edit = Change Char |Copy |Delete |Insert Char |Kill
                deriving (Eq,Show)
-- Transforming one string into another, optimally.
transform :: String -> String -> [Edit]
transform [ ] [ ] =  []
transform xs [ ] =  [Kill]
transform [ ] ys =  map Insert ys
transform (x:xs) (y:ys)
  | x==y        =             Copy : transform xs ys
  | otherwise    =  best [ Delete : transform xs (y:ys) ,
                                   Insert y : transform (x:xs) ys,
                                   Change y : transform xs ys ]
--  choose the sequence with the lowest cost.
best :: [ [Edit] ] -> [Edit]
best [ x ]   =  x
best (x:xs)
           | cost x <= cost b    = x
           | otherwise           = b
              where
              b = best xs
-- The cost is given by charging one for every operation except copy.
cost :: [Edit] -> Int
cost = length . filter (/=Copy)
-----------------------------------------------------

-- When I run the program as listed above,with the simple strings shown,
-- the 'optimal' solution is given by

-- transform "AZ" "5Z"  == [Change '5',Copy]

-- but when I replace 'best' with 'concat' in the transform
-- function to see all the possibilities, some strange solutions appear.
--concat gave me one long list, which i tried to break into all the possible
solutions.
- I numbered the 6 ?? possibilities below, and noticed  #5 doesn't provide
any
-- solution at all, and there are 2 'optimal' solutions.
-----------------------------------------------------------------
--transform "AZ" "5Z"  (using 'concat' instead of 'best' )
--  1 [Delete,Delete,Insert '5',Insert 'Z',
--  2 Insert '5',Copy,
--  3 Change '5',Insert 'Z',
--  4 Insert '5',Delete,Copy,
--  5 Insert 'Z',Kill, Change 'Z',Kill,
--  6 Change '5',Copy]
---------------------------------------
- -First, I really would like to know how to print ALL the possibilities as
a list of lists as they are produced
-- in order by the various function calls, not one long list as concat does.
This would let me see how the
-- recursion steps work as well.
-- Secondly, what is happening in #5 possibility above ? The program never
seems to me to check
-- anywhere that (x:xs) has actually become (y:ys). Since "AZ" is really
seen as 'A' : 'Z' : [ ], then some
--  'terminal' case involving [ ]'s  ends the recursion each time, and that
should produce a correct possible sequence?
-- It appears this can end up as an error.
-- A good explanation will go a long ways in my understanding  of this small
aspect of Haskell.
-- I can only hope one of you has the time and patience to answer this
beginner. Thx.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100730/9c1d89e8/attachment.html

------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 25, Issue 59
*****************************************

Reply via email to