Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-08 Thread Kim-Ee Yeoh
Seth Gordon wrote: Functors are a generalization from lists to things that can be mapped over in general, and then monads are a generalization of functors. Way to go! That way lies true co/monadic enlightenment. Put another way, monads are no more about (only) IO/sequencing than fmap is

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-08 Thread Seth Gordon
Kim-Ee Yeoh wrote: Seth Gordon wrote: Functors are a generalization from lists to things that can be mapped over in general, and then monads are a generalization of functors. Way to go! That way lies true co/monadic enlightenment. I feel like I still don't understand comonads. Maybe I

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-03 Thread David Menendez
On 8/1/07, Jeff Polakow [EMAIL PROTECTED] wrote: But what about an actual object of type 'IO Int', say? I usually describe the type resulting from applying a monad a computation. Same here. If m is a monad, then m a is a computation. (Of course, computations are first-class values, like

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Alexis Hazell
On Thursday 02 August 2007 15:57, ok wrote: It all depends on what you mean make sense to. I can tell my student that (an instance of Monad) is a type constructor applications of which support certain operations that must satisfy certain operations. They can memorise that. But it remains

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Dougal Stanton
On 02/08/07, Alexis Hazell [EMAIL PROTECTED] wrote: It's at this point that i feel there's an issue. Haskell Monads are used FOR many many things. And rather than get to the core of what a Monad is, many people provide two or three motivating examples - examples which merely serve to show

RE: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of peterv However, one thing which I find annoying is that a classic pure function cannot evaluate an IO function unless you use unsafePerformIO; one must promote (?demote) the pure function into the IO monad. That's just a

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Stuart Cook
On 8/2/07, Dougal Stanton [EMAIL PROTECTED] wrote: Do I have an suggestions? Well, maybe the right way would be to do as we do with map and fold, etc: show the explicitly recursive example, then generalise. So, show how we could we would thread state in Haskell, or how we would do optional

Re: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-02 Thread Dan Weston
Ok, I am guessing that if you were Neo in The Matrix, you would have taken the Blue Pill. Blue Pill people ask How. I suspect most people attracted to Haskell have already taken the Red Pill. Red Pill people ask Why. It is compulsion, not self-interest, that drives Red Pill people to look

[Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Kaveh Shahbazian
This is about to put a definition/description to test. So please cooperate! ;) Is this a useful – sufficient, not complete – definition/description for a monad; for an imperative mind: (?) A monad is like a loop that can run a new function against it's variable in each iteration. (I insist on

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Alexis Hazell
On Wednesday 01 August 2007 17:02, Kaveh Shahbazian wrote: This is about to put a definition/description to test. So please cooperate! ;) Is this a useful – sufficient, not complete – definition/description for a monad; for an imperative mind: (?) A monad is like a loop that can run a new

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Dougal Stanton
On 01/08/07, Andrew Wagner [EMAIL PROTECTED] wrote: This seems wrong to me. A monad is, first and foremost, a type constructor class. I'm not sure how you can really compare that to a loop. But perhaps the easiest way to test your definition would be to ask this: How is, for example, the Maybe

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread david48
On 8/1/07, Andrew Wagner [EMAIL PROTECTED] wrote: This seems wrong to me. A monad is, first and foremost, a type constructor class. I'm not sure how you can really compare that to a loop. But perhaps the easiest way to test your definition would be to ask this: How is, for example, the Maybe

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread david48
On 8/1/07, Andrew Wagner [EMAIL PROTECTED] wrote: you can imagine each of the calls to putStrLn gets implicitly passed a variable (here, the world ) and they happen in succession so it's like a loop. It breaks down further as soon as you add any amount of complexity to the code as well.

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Christopher L Conway
On 8/1/07, david48 [EMAIL PROTECTED] wrote: As a beginner haskeller coming from an imperative experience, I think I understood what he meant. say you have this code : putStrLn 1 putStrLn 2 putStrLn 3 you can imagine each of the calls to putStrLn gets implicitly passed a variable

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Andrew Wagner
say you have this code : putStrLn 1 putStrLn 2 putStrLn 3 you can imagine each of the calls to putStrLn gets implicitly passed a variable (here, the world ) and they happen in succession so it's like a loop. It breaks down further as soon as you add any amount of complexity to the

FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread peterv
Kaveh A monad is like a loop that can run a new function against its variable in each iteration. I’m an imperative programmer learning Haskell, so I’m a newbie, but I’ll give it a try ☺ Making mistakes is the best way to learn it ;) There are lots of different kinds of monads, but let’s stick

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Dan Piponi
On 8/1/07, Andrew Wagner [EMAIL PROTECTED] wrote: For me, I think the key to monads is to really understand 2 things about them: ... 2.) Monads are about sequencing Now I disagree on 2. Monads are no more about sequencing than binary operators are about sequencing. Sure, if you want to, you

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Andrew Wagner
an IO monad is a delayed action that will be executed as soon as that action is needed for further evaluation of the program. I'm not sure I like this, as it seems to confuse the issue. An expert should correct me if I'm wrong, but monads in and of themselves don't depend on laziness.

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Seth Gordon
My own perspective on monads is this: In procedural and OO languages, when dealing with compound data structures, we think in terms of getters (*taking data out* of the structure) and setters (*putting data in* to the structure). Languages with some impure functional features (Lisp, Scheme,

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Jeff Polakow
Hello, On 8/1/07, Andrew Wagner [EMAIL PROTECTED] wrote: For me, I think the key to monads is to really understand 2 things about them: ... 2.) Monads are about sequencing Now I disagree on 2. Monads are no more about sequencing than binary operators are about sequencing. Sure, if

Re: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread alpheccar
Kaveh A monad is like a loop that can run a new function against its variable in each iteration. I’m an imperative programmer learning Haskell, so I’m a newbie, but I’ll give it a try ☺ Making mistakes is the best way to learn it ;) I was a newbie not so long ago so I can understand

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Dan Weston
Here's my rant about the way monads are explained in Haskell tutorials (which are much too polluted with nuclear waste to be safely approached): It is a big mistake to start with the IO monad. It pollutes and misdirects the understanding of what a monad is. The dreaded nuclear waste metaphor

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Jeff Polakow
Hello, 'Monad' is a type class. So what's 'IO'? Is the correct terminology 'instance' as in 'IO is an instance of Monad'. I consider 'IO' to be 'a monad' as that fits with mathematical terminology. I agree with this. But what about an actual object of type 'IO Int', say? I usually

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Claus Reinke
a Monad is a type constructor with two operations, implementing a standard interface and following a few simple rules. the Monad type class tells you the interface (what operations you've got, and their types), the Monad laws tell you what all types implementing that interface should have in

Re: FW: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Dan Weston
I knew someone was going to catch me wandering into the deep end of the pool! Having read large parts of your blog, I would never presume to tell you anything about Haskell or category theory, but what the hell... I mostly sympathise with your rant, but I think you need to be clearer about

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread Alexis Hazell
On Thursday 02 August 2007 08:17, Claus Reinke wrote: a Monad is a type constructor with two operations, implementing a standard interface and following a few simple rules. . . . . and this is one of the best definitions i've seen yet. Thanks Claus! i think we need to be looking at What is a

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread ok
Someone asked about comparing monads to loops. If you are chiefly familiar with the i/o and state monads, that doesn't really make a lot of sense, but there IS a use of monads which IS a kind of loop. Only yesterday I was trying to read someone else's Haskell code where they had imported

Re: RE [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread ok
On 2 Aug 2007, at 5:13 am, alpheccar wrote: I think the problem is due to a few bad tutorial still available on the web and which are making two mistakes: 1 - Focusing on the IO monad which is very special ; 2 - Detailing the implementation. As a newie we don't care and we would prefer to

Re: [Haskell-cafe] Monad Description For Imperative Programmer

2007-08-01 Thread ok
On 2 Aug 2007, at 1:20 pm, Alexis Hazell wrote: Category theorists can define monads concisely using the language of their discipline - surely we can settle on a definition of Haskell Monads that would make sense to any programmer who has mastered basic programming concepts? It all depends