[Haskell-cafe] Re: Re: Re: monad subexpressions
Chris Smith
cdsmith at twu.net
Fri Aug 3 15:55:21 EDT 2007
david48 <dav.vire+haskell at gmail.com> wrote:
> On 8/3/07, Neil Mitchell <ndmitchell at gmail.com> 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) => Num (m n)
or some such nonsense. :)
> If you meant :
>
> x <- return 12
> let x = ( <- x )
This would be equally wrong. Perhaps you meant:
do let x = return 12
let x = (<- x)
...
Then this would become:
do let x = return 12
t1 <- x
let x = t1
...
Which is, in turn:
let x = return 12 in x >>= (\t1 -> let x = t1 in ...)
--
Chris Smith
More information about the Haskell-Cafe
mailing list