
#13953: forall -------------------------------------+------------------------------------- Reporter: zaoqi | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: invalid | Keywords: forall Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid Comment: This is completely expected behavior. To recap, the difference between your two programs is that the former program has this: {{{#!hs u :: forall x xs. Usuccs '[x] xs => x -> U xs u x = usuccs (UOne x :: U '[x]) }}} Which typechecks. The latter program: {{{#!hs u :: Usuccs '[x] xs => x -> U xs u x = usuccs (UOne x :: U '[x]) }}} Which lacks an explicit `forall`, does not typecheck. The reason is because by default, the type variables in a function's type signature do not scope over the function body. To enable this behavior, you have to turn on `ScopedTypeVariables` and quantify the type variables explicitly with a `forall`. Refer to [https://downloads.haskell.org/~ghc/8.0.2/docs/html/users_guide/glasgow_exts.... #decl-type-sigs this section] of the users' guide for more information. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13953#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler