[Haskell-cafe] let vs do?

Greg Meredith lgreg.meredith at biosimilarity.com
Fri Jun 29 02:15:29 EDT 2007


Thomas, Stefan,

Thanks for a most edifying exchange! i will reflect on this.

Best wishes,

--greg

On 6/28/07, Stefan Holdermans <stefan at cs.uu.nl> wrote:
>
> Thomas,
>
> >   let x = ... in ...
> >
> > is only equal
> >
> >   do x <- ...; ...
> >
> > in the Identity monad.  Also, why would "do" be more primitive than
> > "let".  That way you would have to use monads everywhere.  Also,
> > let is treated specially by the type checker (IIRC) and there are
> > many, many other reasons not to do that.
>
> As you already hinted at in a later message, this has to do with let-
> bindings being potentially polymorphic and monadic bindings being
> necessarily monomorphic:
>
>    import Control.Monad.Identity
>    foo =               let id =          \x -> x  in        (id 'x',
> id 42) -- well-typed
>    bar = runIdentity $ do  id <- return (\x -> x) ;  return (id 'x',
> id 42) -- ill-typed
>
> Cheers,
>
>    Stefan
>



-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
505 N 72nd St
Seattle, WA 98103

+1 206.650.3740

http://biosimilarity.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070628/e0556bd1/attachment.htm


More information about the Haskell-Cafe mailing list