小编Bry*_*ier的帖子

如何使用函数类型依赖来导出类型参数的相等性?

请考虑以下代码:

{-# LANGUAGE RankNTypes, MultiParamTypeClasses, FunctionalDependencies #-}

data St t = St
    {       use_t :: t
    }

class S s t | s -> t
    where   -- Nothing really

newtype P s = P
    {       unP :: forall b t. (S s t) =>
                    St t
            ->      (St t -> b)     -- pok
            ->      b
    }

f :: (S s t) => t -> P s
f t = P $ \s pok -> pok s { use_t = t …
Run Code Online (Sandbox Code Playgroud)

haskell

5
推荐指数
1
解决办法
72
查看次数

标签 统计

haskell ×1