Re: Yet Another Monad Tutorial

2003-08-26 Thread Wolfgang Jeltsch
On Thursday, 2003-08-14, 13:37, CEST, blaat blaat wrote: > [...] Hello, I don't know exactly which of the following questions have already been answered but I decided to answer them all anyway. > What is the difference between putStr "a", (putStr "a", putStr "a"), putStr > (putStr "a"), putStr

Re: Yet Another Monad Tutorial

2003-08-15 Thread Lars Lundgren
On Thu, 14 Aug 2003, blaat blaat wrote: > > To many questions, not enough mail. First, thanks for all your replies. > Second, I stand totally corrected on the fact that we cannot break down > monads. Functions of type m a->b are called impure, Haskell is a pure language, so there are *no* impu

Re: Yet Another Monad Tutorial

2003-08-15 Thread Bernard James POPE
Hi all, I've been following this discussion with some interest. Last time I looked, hugs, ghc and nhc98 all implemented I/O differently. No doubt there are even more alternatives in other Haskell implementations (real or imaginary). In itself this is probably not too surprising. They are, after

Re: Yet Another Monad Tutorial

2003-08-14 Thread Wolfgang Jeltsch
On Tuesday, 2003-08-12, 12:14, CEST, Alistair Bayley wrote: > [...] > > Care to explain why you think Haskell is not pure? > > Purely functional = you are always defining and calling pure functions. > Calling a pure function with the same arguments always gives the same > results. In Haskell, if

Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Hello everyone, Due to the scarcity of monad tutorials available (:^), I have written one of my own. I hope that this one is both more gentle and more comprehensive than many of the other tutorials out on the 'net, and I am looking for feedback from experienced Haskellers and novices alike. You

RE: Yet Another Monad Tutorial

2003-08-14 Thread Phil Molyneux
ld at some point mention some definitions of monads, monoids et al --- since this is where the power (sorry, QA) comes from. Phil On Tue, 12 Aug 2003, Bayley, Alistair wrote: > Date: Tue, 12 Aug 2003 12:10:24 +0100 > From: "Bayley, Alistair" <[EMAIL PROTECTED]> > Subj

Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Alistair, Thanks for your message regarding the debate about monads and purity. What do you think about these additions as a discussion of the issue? Does this address everything you think is needed? Is there a clearer way to explain it? Thanks, Jeff In the section "No Way Out": -- The

RE: Yet Another Monad Tutorial

2003-08-14 Thread Bayley, Alistair
> -Original Message- > From: Jeff Newbern [mailto:[EMAIL PROTECTED] > > Alistair, > > Hhhmmm. That is an interesting issue, and I am unsure how to treat it > in the tutorial. I did attempt to explain the ability of the monad to > isolate impure computations, but I think I need to make a

Re: Yet Another Monad Tutorial

2003-08-14 Thread Peter G. Hancock
> Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20): (proposed revisions) > In the section "No Way Out": > -- > The IO monad is a familiar example of a one-way monad in Haskell. > Because you can't escape from the IO monad, it is impossible to write a > function th

Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat
Hmmm, I personally always thought of the IO monad as being a synonym for "Program" (or, for functions wich return an IO a, "a subroutine with side-effects which returns a value of type a"). We can build mini programs (like putStr), and compose them in a sequential manner (including something al

Re: Yet Another Monad Tutorial

2003-08-14 Thread Derek Elkins
On Wed, 13 Aug 2003 09:44:36 +0200 "blaat blaat" <[EMAIL PROTECTED]> wrote: > Hmmm, I personally always thought of the IO monad as being a synonym > for "Program" So. What is a "Program"? [...] > For what is the interpretation of an object of type IO a? Well, it is > a bit of a hack atop of

Re: Fwd: Re: Yet Another Monad Tutorial

2003-08-14 Thread Keith Wansbrough
> Think of the following though experiment. What if I would have a function > "unparse:IO a->String" which gives the textual representation of the > specification of the object of type IO a? Clearly, IO is not a monad > anymore. Moreover, I don't think it would break the purity of Haskell. And

Fwd: Re: Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat
From: Derek Elkins <[EMAIL PROTECTED]> "blaat blaat" <[EMAIL PROTECTED]> wrote: [...] > However, given that observation, the fact that IO is a monad I find to > be a _rather arbitrary design decision_; why not define a small term > language which may be passed to the OS? That would be confusing t

Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Peter, Thank you for criticism. This is exactly the kind of feedback I need. The overall message I have taken from your post is that I need to be more precise to convey the correct information and avoid confusion (or worse, misinformation). I should have said that a function which performs a co

Re: Fwd: Re: Yet Another Monad Tutorial

2003-08-14 Thread Iavor Diatchki
hello, sorry for asking so many questions :-) blaat blaat wrote: ... Hmmm, uhm, but let's think further... What did we lose? Well, introspection comes to mind. A monad is strange in the sense that, actually, there does not seem to be any reason to compute its value since we cannot possibly get

Re: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Hello, I have put up all-in-one archives of the tutorial for people who prefer to read it offline. http://www.nomaware.com/monads/monad_tutorial.tgz and http://www.nomaware.com/monads/monad_tutorial.zip Thanks, Jeff Newbern [EMAIL PROTECTED] __ Do you Yahoo!?

Re: Yet Another Monad Tutorial

2003-08-14 Thread Malcolm Wallace
> "blaat blaat" <[EMAIL PROTECTED]> wrote: > > > > However, given that observation, the fact that IO is a monad I find to > > be a _rather arbitrary design decision_; why not define a small term > > language which may be passed to the OS? Derek Elkins <[EMAIL PROTECTED]> writes: > That would be

Re: Yet Another Monad Tutorial

2003-08-14 Thread Dominic Fox
> I suspect that tutorials should at some point mention some > definitions of monads, monoids et al --- since this is where the power > (sorry, QA) comes from. I was reading an overview-for-non-specialists of category theory earlier today, and was surprised by the familiarity of much of it - based

RE: Yet Another Monad Tutorial

2003-08-14 Thread Bayley, Alistair
> From: Wolfgang Jeltsch [mailto:[EMAIL PROTECTED] > > For example, the function readFile is pure. For a specific > string s the > expression readFile s always yields the same result: an I/O > action which > searches for a file named s, reads its content and takes this > content as the > res

Re: Yet Another Monad Tutorial

2003-08-14 Thread Ross Paterson
On Tue, Aug 12, 2003 at 03:04:39PM -0400, Antony Courtney wrote: > So then, in your view, what *is* an IO action? > > One conceptual model is that an IO action with type (IO a) denotes a > function of type World -> (World,a). But the IO monad is not a state monad, because other agents may change

AW: Yet Another Monad Tutorial

2003-08-14 Thread Markus . Schnell
> The overall message I have taken from your post is that I need to > be more precise to convey the correct information and avoid confusion > (or worse, misinformation). As I understood it, the tutorial should be instructive. So I would not try to be more precise at the beginning, because too much

Re: Yet Another Monad Tutorial

2003-08-14 Thread Wolfgang Jeltsch
On Tuesday, 2003-08-12, 18:20, CEST, Jeff Newbern wrote: > [...] > In the section "No Way Out": > -- > The IO monad is a familiar example of a one-way monad in Haskell. Because > you can't escape from the IO monad, it is impossible to write a function > that does a computation in the IO mo

Re: Yet Another Monad Tutorial

2003-08-14 Thread Keith Wansbrough
> Hello everyone, > > Due to the scarcity of monad tutorials available (:^), I have > written one of my own. I hope that this one is both more gentle > and more comprehensive than many of the other tutorials out on > the 'net, and I am looking for feedback from experienced > Haskellers and novice

Re: Yet Another Monad Tutorial

2003-08-14 Thread Antony Courtney
Peter G. Hancock wrote: Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20): ? > The functions exported from the IO module do not > perform I/O themselves. They return I/O actions, which describe an I/O > operation to be performed. The I/O actions are combined within the IO > monad (i

Re: Yet Another Monad Tutorial

2003-08-14 Thread blaat blaat
To many questions, not enough mail. First, thanks for all your replies. Second, I stand totally corrected on the fact that we cannot break down monads. Functions of type m a->b are called impure, see also unsafePerformIO. I am questioning (a) the exact relation between monads, monadic IO, IO in

Re: Yet Another Monad Tutorial

2003-08-14 Thread Derek Elkins
On Tue, 12 Aug 2003 23:15:30 +0200 Wolfgang Jeltsch <[EMAIL PROTECTED]> wrote: > On Tuesday, 2003-08-12, 18:20, CEST, Jeff Newbern wrote: > > [...] > > > In the section "No Way Out": > > -- > > The IO monad is a familiar example of a one-way monad in Haskell. > > Because you can't escape

RE: Yet Another Monad Tutorial

2003-08-14 Thread Jeff Newbern
Alistair, Hhhmmm. That is an interesting issue, and I am unsure how to treat it in the tutorial. I did attempt to explain the ability of the monad to isolate impure computations, but I think I need to make a better explanation of what an action is and how it is used. As for the question of whet

RE: Yet Another Monad Tutorial

2003-08-14 Thread Bayley, Alistair
ECTED] > Sent: 12 August 2003 10:41 > To: [EMAIL PROTECTED] > Subject: Yet Another Monad Tutorial > > > Hello everyone, > > Due to the scarcity of monad tutorials available (:^), I have > written one of my own. I hope that this one is both more gentle > and m

Re: Yet Another Monad Tutorial

2003-08-14 Thread Derek Elkins
On Wed, 13 Aug 2003 13:26:34 +0200 "blaat blaat" <[EMAIL PROTECTED]> wrote: I have a long reply, perhaps I'll post it later. Here's a more pragmatic short one. > What did we lose? Well, introspection comes to mind. A monad is > strange in the sense that, actually, there does not seem to be any >

Re: Yet Another Monad Tutorial

2003-08-14 Thread Wolfgang Jeltsch
On Tuesday, 2003-08-12, 13:10, Alistair Bayley wrote: > > From: Wolfgang Jeltsch [mailto:[EMAIL PROTECTED] > > > > For example, the function readFile is pure. For a specific string s the > > expression readFile s always yields the same result: an I/O action which > > searches for a file named s, re

Re: Yet Another Monad Tutorial

2003-08-12 Thread Peter Robinson
Definitely the most comprehensive monads tutorial on the net. Great stuff! Thanks, Peter On Tuesday 12 August 2003 11:40, Jeff Newbern wrote: > Hello everyone, > > Due to the scarcity of monad tutorials available (:^), I have > written one of my own. I hope that this one is both more gentle > a