[Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Chris Smith
Neil Mitchell [EMAIL PROTECTED] wrote: Right. In effect, as a matter of fact, the notation x - a would become equivalent to let x = (- a) Hmm, interesting. Consider: let x = 12 let x = (- x) Okay, so the desugaring process wouldn't terminate in that case! One could

[Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Chris Smith
david48 [EMAIL PROTECTED] wrote: On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote: Hmm, interesting. Consider: let x = 12 let x = (- x) Wouldn't that be forbidden ? I'd expect the x in ( - x ) have to be of type m a. Yes, unless of course you did: instance (Monad m, Num n)

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Josef Svenningsson
On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote: Neil Mitchell [EMAIL PROTECTED] wrote: I'm not convinced either, a nice concrete example would let people ponder this a bit more. I tried to provide something in my response to Simon. Here it is again: One could sugar: do tax -

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Neil Mitchell
Hi let x = 12 let x = (- x) Okay, so the desugaring process wouldn't terminate in that case! One could either: (a) try to retain the equivalence in theory, but make it illegal to use x in a monadic subexpression when defining x; (b) we could abandon my claim that they are equivalent.

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Neil Mitchell
Hi if you write : let x = (-a):x is it possible that is desugars into : temp -a let x = temp:x that would'nt work ? That would work, since 'a' doesn't refer to 'x'. I can't think of a real example where it becomes an issue, but the scope within 'a' has changed. Also : do case x of

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread david48
On 8/3/07, Neil Mitchell [EMAIL PROTECTED] wrote: temp - a let x = temp if you write : let x = (-a):x is it possible that is desugars into : temp -a let x = temp:x that would'nt work ? I realize I may be asking dumb questions but being dumb never harmed anyone so :) Also : do case x of

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Neil Mitchell
Hi do case x of [] - return 1 (y:ys) - g y = \temp - f temp See the rule about always binding to the previous line of a do block. This case then violates that. I assumed that the example was equivalent to : do case x of [] - return 1 (y:ys)

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Antoine Latter
On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote: Yes, unless of course you did: instance (Monad m, Num n) = Num (m n) or some such nonsense. :) I decided to take this as a dare - at first I thought it would be easy to declare (Monad m, Num n) = m n to be an instance of Num (just lift or

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Twan van Laarhoven
Antoine Latter wrote: On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote: Yes, unless of course you did: instance (Monad m, Num n) = Num (m n) or some such nonsense. :) I decided to take this as a dare - at first I thought it would be easy to declare (Monad m, Num n) = m n to be an