Send Beginners mailing list submissions to
        [email protected]

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
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1.  Re: WWAAA... I hate monads (Ertugrul Soeylemez)
   2. Re:  Re: WWAAA... I hate monads (Federico Brubacher)
   3. Re:  Re: WWAAA... I hate monads (Michael Snoyman)
   4. Re:  Re: WWAAA... I hate monads (Brent Yorgey)
   5. Re:  Re: WWAAA... I hate monads (Daniel Carrera)
   6. Re:  generating the set of all finite-valued ...
      (Erik Quaeghebeur)
   7.  Re: WWAAA... I hate monads (Ertugrul Soeylemez)
   8. Re:  doing state right (Floptical Logic)


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

Message: 1
Date: Fri, 24 Apr 2009 16:18:01 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: [Haskell-beginners] Re: WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

[email protected] wrote:

> > thanks for all your positive comments about my tutorial, both here
> > and through direct email.  I appreciate that very much. =)
> >
> > I'm glad that my work is helpful to the community.
>
> Would you provide a PDF version along with the HTML version?

That will require me to write another XSLT stylesheet, something which I
was going to do anyway, but haven't done yet.  If you would like to
convert it yourself, you'll find the original source files here:

  * http://ertes.de/articles/monads.xml
  * http://ertes.de/articles/Article.xsl
  * http://ertes.de/articles/Article.rng


Greets,
Ertugrul.


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/




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

Message: 2
Date: Fri, 24 Apr 2009 11:37:10 -0300
From: Federico Brubacher <[email protected]>
Subject: Re: [Haskell-beginners] Re: WWAAA... I hate monads
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

While i agree to some extent that analogies are bad in some sense , i found
this one really insightful when i was trying to put my head around monads :
http://www.haroldtherebel.com/2007/12/02/monads-and-schroedingers-cat/

what do u guys think ?



On Fri, Apr 24, 2009 at 11:18 AM, Ertugrul Soeylemez <[email protected]> wrote:

> [email protected] wrote:
>
> > > thanks for all your positive comments about my tutorial, both here
> > > and through direct email.  I appreciate that very much. =)
> > >
> > > I'm glad that my work is helpful to the community.
> >
> > Would you provide a PDF version along with the HTML version?
>
> That will require me to write another XSLT stylesheet, something which I
> was going to do anyway, but haven't done yet.  If you would like to
> convert it yourself, you'll find the original source files here:
>
>  * http://ertes.de/articles/monads.xml
>  * http://ertes.de/articles/Article.xsl
>  * http://ertes.de/articles/Article.rng
>
>
> Greets,
> Ertugrul.
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://blog.ertes.de/
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Federico Brubacher
www.fbrubacher.com

Colonial Duty Free Shop
www.colonial.com.uy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090424/8b0b91e8/attachment-0001.htm

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

Message: 3
Date: Fri, 24 Apr 2009 17:53:22 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Re: WWAAA... I hate monads
To: Federico Brubacher <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

On Fri, Apr 24, 2009 at 5:37 PM, Federico Brubacher <[email protected]>wrote:

> While i agree to some extent that analogies are bad in some sense , i found
> this one really insightful when i was trying to put my head around monads :
> http://www.haroldtherebel.com/2007/12/02/monads-and-schroedingers-cat/
>
> what do u guys think ?
>

I could be wrong here, but isn't he really describing functors and not
monads?

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090424/eba83a38/attachment-0001.htm

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

Message: 4
Date: Fri, 24 Apr 2009 11:11:44 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Re: WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

On Fri, Apr 24, 2009 at 05:53:22PM +0300, Michael Snoyman wrote:
> On Fri, Apr 24, 2009 at 5:37 PM, Federico Brubacher 
> <[email protected]>wrote:
> 
> > While i agree to some extent that analogies are bad in some sense , i found
> > this one really insightful when i was trying to put my head around monads :
> > http://www.haroldtherebel.com/2007/12/02/monads-and-schroedingers-cat/
> >
> > what do u guys think ?
> >
> 
> I could be wrong here, but isn't he really describing functors and not
> monads?

Well, it isn't quite clear, because the explanation seems sort of confused.

The "monads are a box that you can keep stuff in but can't get stuff
out of" metaphor is not new (google "monad space suit") and in my
opinion is somewhat unhelpful, for several reasons:

  (1) with many monads, you CAN "get stuff out of the box"; but how
      you do so is specific to each monad.  

  (2) As pointed out by Michael, the explanation in the linked blog
      post seems to conflate fmap and (>>=), or at least glosses over
      the difference.  But this is a very crucial difference that you
      must understand to manipulate anything more concrete than
      imaginary boxes containing cats.

-Brent


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

Message: 5
Date: Fri, 24 Apr 2009 18:09:40 +0200
From: Daniel Carrera <[email protected]>
Subject: Re: [Haskell-beginners] Re: WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Federico Brubacher wrote:
> While i agree to some extent that analogies are bad in some sense , i 
> found this one really insightful when i was trying to put my head around 
> monads : 
> 
> http://www.haroldtherebel.com/2007/12/02/monads-and-schroedingers-cat/
> 
> what do u guys think ?

Personally, I don't find this analogy useful. Because monads are 
obviously not Schrödinger's cat, the analogy makes me feel like I don't 
actually have any idea of what monads are.

There are other things that I thought were more confusing than useful: 
If you have a monad (m a) you do not "put a function (a -> b) into the 
box". First of all, the second parameter of the bind operator does not 
have the signature (a -> b). It has the signature (a -> m b).

Another problem with saying box or wrapper, which Ertugrul pointed out 
when I said "wrapper" is that the monad may not always return the same 
result. To quote Ertugrul: "An IO computation can give different results 
in each run".

Finally, the analogy with Schrödinger doesn't seem apt. The point of 
Schrödinger's cat is that he is simultaneously dead and alive until you 
open the box to make a measurement. This is not how monads behave. It is 
*not* a property of Schrödinger's cat that you can't interact with the 
cat. Sure you can, just make a measurement.

Finally, this page doesn't have all the detailed explanation that is 
necessary to make an analogy really work.

Daniel.


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

Message: 6
Date: Fri, 24 Apr 2009 18:20:30 +0200 (CEST)
From: Erik Quaeghebeur <[email protected]>
Subject: Re: [Haskell-beginners] generating the set of all
        finite-valued ...
To: Brent Yorgey <[email protected]>,      Jan Jakubuv
        <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII

>> On Fri, Apr 24, 2009 at 12:16:06AM +0200, Erik Quaeghebeur wrote:
>>>
>>>     m = mapM (\x -> [(x,-1),(x,0),(x,1)]) ['a','b','c']
>>>     map (\x -> snd $ unzip x) m
>>>
>>> Any more direct way of doing this?

> On Fri, Apr 24, 2009 at 11:36:44AM +0100, Jan Jakubuv wrote:
>>
>> Well, you can write:
>>
>>     mapM (const [-1,0,1]) [1..3]

On Fri, 24 Apr 2009, Brent Yorgey wrote:
>
> Better yet (in my opinion), you can just write
>
>      sequence (replicate 3 [-1,0,1])
>
> which is really the same thing, since mapM = sequence . map.  Mapping
> (const [-1,0,1]) over [1..3] yields [[-1,0,1], [-1,0,1], [-1,0,1]],
> that is, (replicate 3 [-1,0,1]).  It's the 'sequence' that does the
> magic of selecting an item from each of the three lists in all
> possible ways.

Yes, now I see it, thanks to both Jan and Brent.
I can nicely generalize this to

        n = ...
        values = [...]
        sequence (replicate n values)

My ideas about how I should approach other aspects of my programming task 
are also crystallizing. Now find a nice stretch of time to work things 
out...

Erik


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

Message: 7
Date: Fri, 24 Apr 2009 19:19:41 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: [Haskell-beginners] Re: WWAAA... I hate monads
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Daniel Carrera <[email protected]> wrote:

> > While i agree to some extent that analogies are bad in some sense ,
> > i found this one really insightful when i was trying to put my head
> > around monads :
> >
> > http://www.haroldtherebel.com/2007/12/02/monads-and-schroedingers-cat/
> >
> > what do u guys think ?
>
> Personally, I don't find this analogy useful. Because monads are
> obviously not Schrödinger's cat, the analogy makes me feel like I
> don't actually have any idea of what monads are.
>
> There are other things that I thought were more confusing than useful:
> If you have a monad (m a) you do not "put a function (a -> b) into the
> box". First of all, the second parameter of the bind operator does not
> have the signature (a -> b). It has the signature (a -> m b).

I think, this is rather an allusion to functors.


> Another problem with saying box or wrapper, which Ertugrul pointed out
> when I said "wrapper" is that the monad may not always return the same
> result. To quote Ertugrul: "An IO computation can give different
> results in each run".

Monadic values (computations, containers, whatever you call them) are
expressed intrinsically without a notion of running them.  Running is
something separate and specific to particular monads.  There may be
monads, which are not supposed to be "run", or for which "running"
doesn't make any sense at all.


> Finally, the analogy with Schrödinger doesn't seem apt. The point of
> Schrödinger's cat is that he is simultaneously dead and alive until
> you open the box to make a measurement. This is not how monads
> behave. It is *not* a property of Schrödinger's cat that you can't
> interact with the cat. Sure you can, just make a measurement.

Actually Schrödinger's cat is neither dead nor alive.  Its state S is a
unit vector living in a Hilbert space.  The two possible measurement
outcomes are also unit vectors in that vector space.  They form an
orthonormal basis, but S isn't equal to either of them.  Measuring S
means turning it into one of them, thereby destroying the original
state.


Greets,
Ertugrul.


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/




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

Message: 8
Date: Fri, 24 Apr 2009 14:07:28 -0500
From: Floptical Logic <[email protected]>
Subject: Re: [Haskell-beginners] doing state right
To: Chadda? Fouch? <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Bah! I completely forgot arrays were constant in lookup.

Thanks

On Thu, Apr 23, 2009 at 3:05 AM, Chaddaï Fouché
<[email protected]> wrote:
> On Thu, Apr 23, 2009 at 10:03 AM, Chaddaï Fouché
> <[email protected]> wrote:
>>
>> main = quick_ppm "foo.ppm" (\i j -> isPrime ((i-1)*limit+j)) limit limit
>>  where
>>    isPrime n = primeSieve ! n
>>    primeSieve :: UArray Int Bool
>>    primeSieve = accumArray (\_ _ -> True) False (0,limit*limit) $ zip
>> primes (repeat ())
>>
>
> That should read as "zip (takeWhile (<= limit*limit) primes) (repeat
> ())" of course.
>
> --
> Jedaï
>


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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 10, Issue 27
*****************************************

Reply via email to