相关疑难解决方法(0)

量化约束与(封闭)类型系列

我正在尝试使用这篇博文的方法来处理更高级的数据,而无需Identity为琐碎的情况使用悬空函子以及量化约束推导:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE QuantifiedConstraints, StandaloneDeriving, UndecidableInstances #-}
module HKD2 where

import Control.Monad.Identity

type family HKD f a where
    HKD Identity a = a
    HKD f        a = f a

data Result f = MkResult
    { foo :: HKD f Int
    , bar :: HKD f Bool
    }

deriving instance (forall a. Show a => Show (HKD f a)) => Show (Result f)
Run Code Online (Sandbox Code Playgroud)

这导致了令人气愤的自相矛盾的错误信息:

无法Show (HKD f a) 从上下文推断:forall a. Show …

haskell type-families deriving quantified-constraints derivingvia

9
推荐指数
2
解决办法
262
查看次数