Re: [Haskell] return?

2004-04-30 Thread Tomasz Zielonka
On Thu, Apr 29, 2004 at 06:27:32PM -0500, [EMAIL PROTECTED] wrote: Hi, While writing monad programs, I sometimes want to do a return as it is in imperative program. i.e., do{return 1; return 2} is same as return 1 Is this possible at all? Someone already proposed an Error monad, but I

Re: [Haskell] return?

2004-04-30 Thread John Meacham
On Thu, Apr 29, 2004 at 06:27:32PM -0500, [EMAIL PROTECTED] wrote: While writing monad programs, I sometimes want to do a return as it is in imperative program. i.e., do{return 1; return 2} is same as return 1 I know I can do if cond then return 1 else ( ...--subsequent actions )

Re: [Haskell] return?

2004-04-30 Thread Chung-chieh Shan
On 2004-04-29T18:27:32-0500, [EMAIL PROTECTED] wrote: While writing monad programs, I sometimes want to do a return as it is in imperative program. i.e., do{return 1; return 2} is same as return 1 Hello, You can build an error monad transformer along the lines of the Control.Monad.Error

Re: [Haskell] return?

2004-04-30 Thread Graham Klyne
Is this possible at all? I don't think so, in the form that you suggest. Ultimately, it all comes down to function applications, for which there is no such bail out. Rather, I think something like this is required: do { ... ; if cond then return 1 else do (the rest)

Re: [Haskell] return?

2004-04-30 Thread Hal Daume III
], [EMAIL PROTECTED] g cc: Subject: Re: [Haskell] return

Re: [Haskell] return?

2004-04-30 Thread Ben_Yu
Subject: Re: [Haskell] return? AM

Re: [Haskell] return?

2004-04-30 Thread Ben_Yu
] cc: [EMAIL PROTECTED] 04/30/2004 10:54 Subject: Re: [Haskell] return? AM

Re: [Haskell] return?

2004-04-30 Thread Wolfgang Lux
John Meacham wrote: you can make things somewhat better with this construct foo = do baz if cond then return bar else do bua bam Except that this is invalid according to the Haskell report. In note 1 in section 9.3 (Layout), the report explicitly states that A

[Haskell] return?

2004-04-29 Thread Ben_Yu
Hi, While writing monad programs, I sometimes want to do a return as it is in imperative program. i.e., do{return 1; return 2} is same as return 1 This seems useful to me when I need to do something like do mwhen cond $ return 1 .. -- subsequent actions I know I can do if cond then