我真的很困惑haskell中的类。如果我有代码:类型类在Haskell中如何工作?
class GetResult n where res :: n -> Int
class (GetResult n) => Model n where
starting :: Int -> [Int] -> n
starting i j = .....
test :: n -> n
test n = ......
n是什么类型?开始输出和测试的输入是什么类型?
如果您来自OO背景,请尝试始终将haskell类视为(通用)接口而不是OO类。它们并不完全等效,但给你一个更好的近似值。 – phg