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

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat May 21 15:18:42 CEST 2011


I have no problems in defining those functions:

$ ghci
GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> let id2 :: t -> t; id2 = \x -> x
Prelude> let a :: a -> a; a = a a

Note that I used ';'.  This is equivalent to writing

  let a :: a -> a
      a = a a

If I try the syntax you were trying without ScopedTypeVariables, I get

Prelude> let a :: a -> a = a a
<interactive>:1:4:
    Illegal signature in pattern: a -> a
        Use -XScopedTypeVariables to permit it

GHCi thinks that you were trying to define a function by pattern
matches and there was a signature inside it, which is a different
thing.  This is the expected use for such thing:

Prelude> :s -XScopedTypeVariables
Prelude> let id2 :: forall t. t -> t; id2 (x :: t) = x

Cheers, =)

-- 
Felipe.



More information about the Haskell-Cafe mailing list