我想表达我有 3 个相关的类型类。
我有两个文件。第一的:
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module ModA where
class Class a b c | a -> b, b -> c where
getB :: a -> b
getC :: b -> c
第二:
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
module B where
import qualified ModA
data A = A {f1::String}
data B = B {f2::String}
data C = C {f3::String}
instance ModA.Class A B C where
getB a = B "hey"
getC a = C "ho"
getABForMe = ModA.getB (A "boo")
getACForMe = ModA.getC (B "yo")
我得到的错误:
No instance for (ModA.Class a0 B C)
arising from a use of `ModA.getC'
Possible fix: add an instance declaration for (ModA.Class a0 B C)
In the expression: ModA.getC (B "yo")
In an equation for `getACForMe': getACForMe = ModA.getC (B "yo")
我错过了什么?