This code causes GHC to incorrectly fail - the case *is* reachable.
(I invented this technique in an attempt to directly access the
internal System FC newtype coercion; it promised until a few minutes
ago to solve all the EnumMap performance concerns.)

[EMAIL PROTECTED]:/tmp$ cat A.lhs
> {-# OPTIONS_GHC -fglasgow-exts #-}
>
> data IsIntT x where IsIntT :: IsIntT Int
>
> class IsIntC a where isInt :: IsIntT a
> instance IsIntC Int where isInt = IsIntT
>
> newtype Foo = Foo Int deriving(IsIntC)
>
> x :: IsIntT Foo -> Int
> x IsIntT = (Foo 2) + 2
>
> y = x (isInt :: IsIntT Foo)
[EMAIL PROTECTED]:/tmp$ ghci -v0 A.lhs

A.lhs:11:4:
    Inaccessible case alternative: Can't match types `Foo' and `Int'
    In the pattern: IsIntT
    In the definition of `x': x IsIntT = (Foo 2) + 2

Stefan
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to