[Haskell-cafe] ScopedTypeVariables in let-bindings (not where-bindings!) and bug 4347

Brandon Allbery allbery.b at gmail.com
Sat May 21 17:13:03 CEST 2011


On Sat, May 21, 2011 at 10:49, Paolo Giarrusso <p.giarrusso at gmail.com>wrote:

> On Sat, May 21, 2011 at 16:27, Brandon Allbery <allbery.b at gmail.com>
> wrote:
> > On Sat, May 21, 2011 at 10:17, Paolo G. Giarrusso <p.giarrusso at gmail.com
> >
> > wrote:
> >>
> >> First, thanks to you and everybody for the alternative. But I'm still
> >> convinced that the syntax is supposed to work, and you're just
> >> workarounding the bug.
> >
> > Hm, I think we have differing expectations; the syntax everyone presented
> is
> > the one that is normally used for such things in ghci, and while perhaps
> the
> > one you tried is supposed to work, it's a bit unusual and therefore
> probably
> > not very well tested.
>
> Yes, it was my guess as well - and for some reason I missed the usual
> syntax.
> A sincere question about the usual syntax: where do you learn it? It's
>

It's just the desugaring of layout, with the braces being optional because
it's all on one line.  Since you can't use layout in ghci, you have to
manually convert.  It is perhaps not entirely obvious (I was a bit surprised
when, as a complete Haskell newbie, I decided to try it and it worked) that
you can specify types in both let and where clauses in the same way you do
at the top level:

> let a :: a -> a
>     a = a a
>   where b :: b -> b
>         b = b b

which in its non-layout version is

> let { a :: a -> a; a = a a } where { b :: b -> b; b = b b }

(using the braces here because it's a bit ambiguous; I think H'2010 fixed
that though)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110521/4a707aaf/attachment.htm>


More information about the Haskell-Cafe mailing list