[GHC] #8912: Documentation stale: implicit-parameter constraints seem to be allowed in instance declarations now.

GHC ghc-devs at haskell.org
Wed Mar 19 15:03:26 UTC 2014


#8912: Documentation stale: implicit-parameter constraints seem to be allowed in
instance declarations now.
-------------------------------------+-------------------------------------
       Reporter:  andreas.abel       |             Owner:
           Type:  bug                |            Status:  new
       Priority:  normal             |         Milestone:
      Component:  Documentation      |           Version:  7.6.3
       Keywords:  implicit-          |  Operating System:  Unknown/Multiple
  parameter instance-constraints     |   Type of failure:  Documentation
   Architecture:  Unknown/Multiple   |  bug
     Difficulty:  Easy (less than 1  |         Test Case:
  hour)                              |          Blocking:
     Blocked By:                     |
Related Tickets:                     |
-------------------------------------+-------------------------------------
 http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/other-type-
 extensions.html#implicit-parameters
 says:

  You can't have an implicit parameter in the context of a class or
 instance declaration. For example, both these declarations are illegal:
 {{{
   class (?x::Int) => C a where ...
   instance (?x::a) => Foo [a] where ...
 }}}
 However, ghc 7.6.3 seems to accept this now:
 {{{
   {-# LANGUAGE ImplicitParams #-}

   class C a where
     toInt :: a -> Int

   instance (?imp :: Int) => C [a] where
     toInt _ = ?imp

   test :: Int
   test = let ?imp = 5 in toInt "Hello, world"
 }}}
 test evaluates to 5.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8912>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list