Re: [Haskell-cafe] Monads, do and strictness

2012-01-23 Thread Sebastian Fischer
On Sun, Jan 22, 2012 at 5:25 PM, David Barbour dmbarb...@gmail.com wrote: The laws for monads only apply to actual values and combinators of the monad algebra You seem to argue that, even in a lazy language like Haskell, equational laws should be considered only for values, as if they where

Re: [Haskell-cafe] Monads, do and strictness

2012-01-23 Thread David Barbour
Thanks for the reference. I base my opinion on my own observations - e.g. the repeated failures of attempting to model stream processing with infinite lists, the relative success of modeling exceptions explicitly with monads compared to use of `fail` or SomeException, etc.. On Mon, Jan 23, 2012

Re: [Haskell-cafe] Monads, do and strictness

2012-01-23 Thread Jake McArthur
On Mon, Jan 23, 2012 at 10:45 AM, David Barbour dmbarb...@gmail.com wrote: the repeated failures of attempting to model stream processing with infinite lists, I'm curious about what failures you're talking about. - Jake ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Monads, do and strictness

2012-01-23 Thread David Barbour
Space leaks, time leaks, resource leaks, subtle divergence issues when filtering lists, etc. On Mon, Jan 23, 2012 at 11:57 AM, Jake McArthur jake.mcart...@gmail.comwrote: On Mon, Jan 23, 2012 at 10:45 AM, David Barbour dmbarb...@gmail.com wrote: the repeated failures of attempting to model

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread Sebastian Fischer
On Sat, Jan 21, 2012 at 8:09 PM, David Barbour dmbarb...@gmail.com wrote: In any case, I think the monad identity concept messed up. The property:   return x = f = f x Logically only has meaning when `=` applies to values in the domain. `undefined` is not a value in the domain. We can

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread David Barbour
observably different from `undefined` If we understand `undefined` as meaning a computation that never ends, then you cannot ever observe whether one `undefined` is or is not equivalent to another. In strict languages, this is especially obvious. In any case, I don't accept a concept of

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread MigMit
Отправлено с iPad 22.01.2012, в 20:25, David Barbour dmbarb...@gmail.com написал(а): Attempting to shoehorn `undefined` into your reasoning about domain algebras and models and monads is simply a mistake. No. Using the complete semantics — which includes bottoms aka undefined — is a

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread David Barbour
2012/1/22 MigMit miguelim...@yandex.ru Отправлено с iPad 22.01.2012, в 20:25, David Barbour dmbarb...@gmail.com написал(а): Attempting to shoehorn `undefined` into your reasoning about domain algebras and models and monads is simply a mistake. No. Using the complete semantics — which

[Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Victor S. Miller
The do notation translates do {x - a;f} into a=(\x - f) However when we're working in the IO monad the semantics we want requires that the lambda expression be strict in its argument. So is this a special case for IO? If I wanted this behavior in other monads is there a way to specify

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread MigMit
On 21 Jan 2012, at 21:29, Victor S. Miller wrote: The do notation translates do {x - a;f} into a=(\x - f) However when we're working in the IO monad the semantics we want requires that the lambda expression be strict in its argument. So is this a special case for IO? If I wanted

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Roman Cheplyaka
* Victor S. Miller victorsmil...@gmail.com [2012-01-21 12:29:32-0500] The do notation translates do {x - a;f} into a=(\x - f) However when we're working in the IO monad the semantics we want requires that the lambda expression be strict in its argument. I'm not aware of any semantics

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
As noted, IO is not strict in the value x, only in the operation that generates x. However, should you desire strictness in a generic way, it would be trivial to model a transformer monad to provide it. E.g. data StrictT m a = StrictT (m a) runStrictT :: StrictT m a - m a runStrictT (StrictT

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Steve Horne
On 21/01/2012 17:29, Victor S. Miller wrote: The do notation translates do {x- a;f} into a=(\x - f) However when we're working in the IO monad the semantics we want requires that the lambda expression be strict in its argument. So is this a special case for IO? If I wanted this behavior

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Roman Cheplyaka
* David Barbour dmbarb...@gmail.com [2012-01-21 10:01:00-0800] As noted, IO is not strict in the value x, only in the operation that generates x. However, should you desire strictness in a generic way, it would be trivial to model a transformer monad to provide it. Again, that wouldn't be a

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Steve Horne
On 21/01/2012 18:08, Steve Horne wrote: Even so, to see that strictness isn't the issue, imagine that (=) were rewritten using a unary executeActionAndExtractResult function. You could easily rewrite your lamba to contain this expression in place of x, without actually evaluating that

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
On Sat, Jan 21, 2012 at 10:08 AM, Roman Cheplyaka r...@ro-che.info wrote: * David Barbour dmbarb...@gmail.com [2012-01-21 10:01:00-0800] As noted, IO is not strict in the value x, only in the operation that generates x. However, should you desire strictness in a generic way, it would be

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Menendez
On Sat, Jan 21, 2012 at 1:45 PM, David Barbour dmbarb...@gmail.com wrote: On Sat, Jan 21, 2012 at 10:08 AM, Roman Cheplyaka r...@ro-che.info wrote: * David Barbour dmbarb...@gmail.com [2012-01-21 10:01:00-0800] As noted, IO is not strict in the value x, only in the operation that generates

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
On Sat, Jan 21, 2012 at 10:51 AM, David Menendez d...@zednenem.com wrote: The Eval monad has the property: return undefined = const e = e. You can't write `const e` in the Eval monad. From what I can tell, your proposed monads do not. You can't write `const e` as my proposed monad,

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Roman Cheplyaka
* David Barbour dmbarb...@gmail.com [2012-01-21 11:02:40-0800] On Sat, Jan 21, 2012 at 10:51 AM, David Menendez d...@zednenem.com wrote: The Eval monad has the property: return undefined = const e = e. You can't write `const e` in the Eval monad. Why not? ghci runEval $ return

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
Oops, I was misreading. You have `e` here as the next monad. In any case, I think the monad identity concept messed up. The property: return x = f = f x Logically only has meaning when `=` applies to values in the domain. `undefined` is not a value in the domain. We can define monads - which

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
On Sat, Jan 21, 2012 at 11:08 AM, Roman Cheplyaka r...@ro-che.info wrote: * David Barbour dmbarb...@gmail.com [2012-01-21 11:02:40-0800] On Sat, Jan 21, 2012 at 10:51 AM, David Menendez d...@zednenem.com wrote: The Eval monad has the property: return undefined = const e = e. You

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Roman Cheplyaka
* David Barbour dmbarb...@gmail.com [2012-01-21 11:09:43-0800] Logically only has meaning when `=` applies to values in the domain. `undefined` is not a value in the domain. We can define monads - which meet monad laws - even in strict languages. In strict languages 'undefined' is not a

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Yves Parès
(StrictT op) = f = StrictT (op = \ x - x `seq` runStrictT (f x)) Are you sure? Here you evaluate the result, and not the computation itself. Wouldn't it be: (StrictT op) = f = op ` seq` StrictT (op = \x - runStrictT (f x)) ?? 2012/1/21 David Barbour dmbarb...@gmail.com On Sat, Jan 21, 2012

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread David Barbour
Evaluating the argument/result was my intention. Evaluating the computation itself might be useful in some cases, though. Regards, Dave On Sat, Jan 21, 2012 at 3:20 PM, Yves Parès yves.pa...@gmail.com wrote: (StrictT op) = f = StrictT (op = \ x - x `seq` runStrictT (f x)) Are you sure?