请考虑以下代码:
{-# 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 ×1