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.
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 F a b | a -> b
instance F Int Bool
class D a where { op :: (F a b) => a -> b }
instance (TypeCast Bool b') => D Int where { op _ = typeCast True }
With `TypeCast` defined as for HList.
That dangling type variable `b'` in the constraint is weird.
But GHC still rejects it; and rejects a version with a `(~)` constraint instead of the `TypeCast`.
AntC
_______________________________________________
Hugs-Users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/hugs-users