有了函數依賴,我可以聲明Foo類: class Foo a b c | a -> b where
foo1 :: a -> b -> c
foo2 :: a -> c
,當我打電話foo2,一切工作正常。由於依賴關係,編譯器知道使用哪個實例。 但如果我刪除的依賴創造Foo': class Foo' a b c where
foo1' :: a -> b -> c
我在閱讀Monad Transformers Step by Step。第6頁,同時引入的Monad一些子類,筆者給出了下面的代碼示例: class (Monad m) => MonadError e m | m -> e where
throwError :: e -> m a
catchError :: m a -> (e -> m a) -> m a
class (M
我想表達我有3個相關的類型類。 我有兩個文件。第一: {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module ModA where
class Class a b c | a -> b, b -> c where
getB :: a -> b
getC :: b -> c
二: {-#