为什么这个内射型家族实际上不是单射的?

问题描述 投票:5回答:1

我试过这个:

{-# 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

为什么?当然,注入的全部意义在于,人们可以从a ~ b中推断出F a ~ F b

haskell ghc type-families
1个回答
3
投票

原来这是a known issue in GHC。显然这是因为它没有被证明是合理的。

© www.soinside.com 2019 - 2024. All rights reserved.