在由SPJ this纸,第3页和图4上,它是写: class Mutation m where
type Ref m :: * -> *
newRef :: a -> m (Ref m a)
readRef :: Ref m a -> m a
writeRef :: Ref m a -> a -> m()
instance Mutation IO whe
我明白(->) a是一种* -> *高阶类型,当应用于类型参数b给a -> b 我可以写一个类型的一种* -> *,当应用于c会给a -> b -> c类型? 如果不是,为什么不呢?也许使用一些语言扩展和forall? 这将让我写函子与应用型(和其它类),其中函子结构是“a -> b ->”的实例如下所示: (<*>) :: Applicative t => t (c -> d) -> t c -
我希望我的术语是正确的。 我要做到以下几点: data Hide a = ∀ b. (A.ToJSON (a b), A.ToJSON b) ⇒ Hide (a b)
mapHide ∷ (∀ c. (A.ToJSON (b c), A.ToJSON c) ⇒ a c → b c) → Hide a → Hide b
mapHide f (Hide a) = (Hide $ f a)
不