Re: [Haskell-cafe] Re: Explaining monads

2007-08-14 Thread Bertram Felgenhauer
Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible things things together in a row. I

[Haskell-cafe] Re: Explaining monads

2007-08-14 Thread Aaron Denney
On 2007-08-14, Dan Piponi [EMAIL PROTECTED] wrote: On 8/14/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: I like the very light weight analogy (which works for most practical uses of monads) that a monadic action is a recipe Many introductory programming books present the idea of a program as

[Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible things things together in a row. /None/ of them force any particular

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brandon S. Allbery KF8NH
On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences these effects, that's what you use it for: the _first_ action to be

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread David Roundy
On Mon, Aug 13, 2007 at 05:13:01PM -0400, Brandon S. Allbery KF8NH wrote: On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Tillmann Rendel
David Roundy wrote: It's the *effect* of a monad, not the *side* effect. The type of = defines this dependency. And when you have a chain of dependencies, that is sometimes referred to as a sequence. True, it's not mystical, but it's still sequenced. How can a Haskell type define a data

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brian Brunswick
On 13/08/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like, and you'll find that regardless of the *data* dependencies (the return value of this monadic action is unambiguous), the undefined is evaluated *before*

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Derek Elkins
On Mon, 2007-08-13 at 22:29 +0200, Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like instance Monad M where return a = M a ~(M a) = f = f a Or is that cheating? -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Arie Peterson
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: | Try executing: | | do { x - return 2; undefined; return (x*x); } | | in any monad you like It's not just the identity monad: Prelude :m +Control.Monad.State Prelude Control.Monad.State flip evalState () $ do { x - return 2; undefined;