[jhc] Rank 2 types error

John Meacham john at repetae.net
Thu Feb 9 00:21:15 CET 2012


On Wed, Feb 8, 2012 at 2:55 PM, Roman Cheplyaka <roma at ro-che.info> wrote:
> The following program is accepted by GHC 7 with -XRank2Types:
>
>    class C a where
>        f :: a -> a
>
>    newtype R = R (forall a . C a => a)
>
>    instance C R where
>        f (R x) = R $ f x
>
>    main = return ()
>
> jhc 0.8 gives the following error:
>
>    [1 of 1] Main             (...............jhci: user error (
>    What:    failure
>    Why:     Signature too Weak: [] does not imply [Main.C Main.v11]
>    Where:   on line 7 in j.hs
>    in the explicitly typed Instance at .iMain.f.Main.R (Main.R Main.6_x)
>      = Main.R Jhc.Basics.$ Main.f Main.6_x             {- on line 7 -}
>    Compilation of module: Main)
>
> Is this difference in behaviour intended, and how can I make something
> like that compile?

I believe that jhc is being too restrictive here and it should accept
the program. thanks for the report. I strengthened the checking of
class constraints signifiantly in this version and probably introduced
this bug.

    John



More information about the jhc mailing list