は、私は、次の型クラスMapping定義したい質問: {-# LANGUAGE MultiParamTypeClasses #-}
class Mapping k v m where
empty :: m v
insert :: k -> v -> m v -> m v
search :: k -> m v -> Maybe v
delete :: k
この質問は、優秀なファンタジーの新しい章を読んでいる間に、アプリケーション・ファンクターについてのハスケルです。 のApplicative型クラスは、たぶん、インスタンスの定義の一部として、があります。 pure = Just
私はちょうどGHCiのと輸入Control.Applicativeに行き、そしてそうした場合: pure (3+)
Iドンちょうど何かを得る(意味をなさない)。私は
Cabbage.hs: module Cabbage where
class Cabbage a
where foo :: a -> String -- the parameter is only present for its type,
-- the parameter value will be ignored
bar :: String -
このデータ型のFoldableインスタンスはどのように見えますか? data X t = X t [X t]
私はこの試みた: instance Foldable X where
foldMap f (X x xs) = f x `mappend` foldMap f xs
をしかし、このエラーを得た: Occurs check: cannot construct the inf