HugsにおけるアグレッシヴすぎるContext Reduction

これ、バグといっていいのかどうか.

Hugs

class TypeCast a b | a->b, b->a where
  typeCast :: a->b
instance TypeCast a a where
  typeCast = id

class Col' a b where
  inCol' :: a -> b
instance TypeCast a b => Col' a [b] where
  inCol' x = [typeCast x]

コンパイルできない.

ERROR "./FunDepsTest.hs":19 - Inferred type is not general enough
*** Expression    : inCol'
*** Expected type : Col' a [b] => a -> [b]
*** Inferred type : Col' a [a] => a -> [a]

typeCastの型が問題.GHC,Hugsどちらでも、最終的に typeCast :: forall a. a->a と推論される(!)が,GHCではモジュールのコンパイル途中では typeCast :: TypeCast a b => a->b となっているため型付けに成功する.一方Hugsはそうではない.

TypeCastのインスタンス宣言を別のモジュールに逃がせばなんとかなる.が,orphan instanceになってしまうのが美しくないね.