为什么这个单射类型的家庭实际上不是单射的?
Why is this injective type family not actually injective?
我试过这个:
{-# LANGUAGE TypeFamilyDependencies #-}
module Injective where
type family F (a :: *) = (fa :: *) | fa -> a
convert :: F a ~ F b => a -> b
convert x = x
GHC 8.6.4 给我这个错误
• Could not deduce: a ~ b
from the context: F a ~ F b
bound by the type signature for:
convert :: forall a b. (F a ~ F b) => a -> b
at Injective.hs:6:1-30
为什么?当然,单射性的全部意义在于 可以 从 F a ~ F b
?
推导出 a ~ b
原来这是a known issue in GHC。显然是因为它还没有被证明是可靠的。
我试过这个:
{-# LANGUAGE TypeFamilyDependencies #-}
module Injective where
type family F (a :: *) = (fa :: *) | fa -> a
convert :: F a ~ F b => a -> b
convert x = x
GHC 8.6.4 给我这个错误
• Could not deduce: a ~ b
from the context: F a ~ F b
bound by the type signature for:
convert :: forall a b. (F a ~ F b) => a -> b
at Injective.hs:6:1-30
为什么?当然,单射性的全部意义在于 可以 从 F a ~ F b
?
a ~ b
原来这是a known issue in GHC。显然是因为它还没有被证明是可靠的。