[Haskell-cafe] Re: Type errors, would extensions help?
Ryan Ingram
ryani.spam at gmail.com
Thu Jan 15 19:02:32 EST 2009
Here's the desugaring:
> do { pattern <- expression ; rest }
desugars to
> expression >>= \temp -> case temp of
> pattern -> do { rest }
> _ -> fail "Pattern match failure"
(where "temp" is a fresh variable not used elsewhere, and the failure
message usually includes source position)
Whereas
> do { let pattern = expression ; rest }
desugars to
> let pattern = expression in do { rest }
-- ryan
On Thu, Jan 15, 2009 at 3:26 PM, Lennart Augustsson
<lennart at augustsson.net> wrote:
> The <- binding is lambda binding (look at how it desugars). Lambda
> bindings are monomorphic without any type extensions. The monadic
> 'let' binding is like regular 'let', so it's a point where the type
> checker does generalization, and so you get (possibly) polymorphic
> bindings from let.
>
> -- Lennart
>
> On Thu, Jan 15, 2009 at 11:20 PM, Mauricio <briqueabraque at yahoo.com> wrote:
>> Thanks, everything works now.
>>
>> What should I read to better understand the difference
>> for the type system between using <- and 'let'? That is
>> not intuitive for me.
>>
>> About layout, I used to filter my code to better fit
>> everyone taste before posting to this list. The filter
>> stoped working due to some problems in 'Language.Haskell',
>> but I'll rewrite it with haskell-src-exts before
>> posting again.
>>
>> Thanks,
>> Maurício
>>
>>> I suggest you start using "let" in your do blocks; both of these
>>> problems are solvable with let.
>>
>>>
>>>
>>> Binding with <- instead of "let" makes the type system work harder,
>>> and will generally require type annotations & extensions for
>>> polymorphic results. (...)
>>
>>> Also, is there a reason you hate the layout rule and are using
>>> explicit semicolons everywhere?
>>>
>>>>>> I have this problem trying to define a function
>>>>>> inside a do expression. (...)
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list