Skip to content

Documentation stale: implicit-parameter constraints seem to be allowed in instance declarations now.

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.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Documentation
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information