[Haskell-cafe] let vs do?
lgreg.meredith at biosimilarity.com
Fri Jun 29 02:15:29 EDT 2007
Thanks for a most edifying exchange! i will reflect on this.
On 6/28/07, Stefan Holdermans <stefan at cs.uu.nl> wrote:
> > 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
505 N 72nd St
Seattle, WA 98103
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe