Using implicit parameter constraints in data decl

Benjamin Franksen benjamin.franksen at bessy.de
Sun Nov 7 13:36:40 EST 2004


On Sunday 07 November 2004 20:09, Simon Peyton-Jones wrote:
| Definitely a bug.  Could you pls make a small module that elicits the
| bug, and send it to me?

Here it is:

> module Test where
> 
> data Test = (?val::Bool) => Test { name :: String }
> 
> instance Show Test where
>     show p = name p

franksen at linux: .../src/testbug > ghc -fimplicit-params TestBug.hs
ghc-6.2.2: panic! (the `impossible' happened, GHC version 6.2.2):
        simplCore/Simplify.lhs:1473: Non-exhaustive patterns in function 
cat_evals

BTW, I see now that the data declaration is syntactically wrong. Anyway, the 
(syntactically) correct version

data (?val::Bool) => Test = Test { name :: String }

is rejected by the compiler:

TestBug.hs:3:
    Illegal constraint ?val :: Bool
    In the context: (?val :: Bool)
    While checking the context of the data type declaration for `Test'
    In the data type declaration for `Test'

which is unfortunate since it means that you cannot put a function that 
depends on an implicit parameter into a data structure. There are probably 
technical reasons for this restriction, but it means that such functions are 
no longer first class objects.

Cheers,
Ben



More information about the Glasgow-haskell-bugs mailing list