gpt4 book ai didi

haskell - 为什么这个单射类型族实际上不是单射的?

转载 作者:行者123 更新时间:2023-12-01 22:19:13 24 4
gpt4 key购买 nike

我尝试过这个:

{-# 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 。显然这是因为它尚未被证明是正确的。

关于haskell - 为什么这个单射类型族实际上不是单射的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55543598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com