props for Hugs over System FC

Anthony Clayden <[email protected]>
Newsgroups gmane.comp.lang.haskell.glasgow.user
Message-ID <CAM7nRYQ0JU5WJ280-S0Bwu+=bU95q+WjAhTbG0P68eFBSZTUCQ@mail.gmail.com>
heh heh. I've got to record this for posterity. I've never known an example
before.

Some code that compiles in Hugs and works fine; but GHC (8.6.4) can't
typecheck so rejects.

It's an example in the 2011 'System F with Type Equality Coercions',
section 2.3 discussing FunDeps; and used to justify the extra power of type
inference in Type Families as opposed to FunDeps. Full details discussed
here: https://gitlab.haskell.org/ghc/ghc/issues/16430#note_189393

    class F a b | a -> b    instance F Int Bool    class D a where {
op :: F a b => a -> b }    instance D Int where { op _ = True }

True that doesn't compile as given. Hugs says: 'Inferred type is not
general enough'.

GHC says 'Couldn't match expected type `b' with actual type `Bool''/
'`b' is a rigid type variable'. (So essentially the same failure of
typechecking.)

With a little help for the type inference, this compiles in Hugs.

    class C a b | a -> b    instance C Int Bool    f :: (C Int b,
TypeCast b Bool) => b -> Bool    f x  = typeCast x

With `TypeCast` defined as for HList.

But GHC still rejects it; and rejects a version with a `(~)`
constraint instead of the `TypeCast`.


AntC

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.