我有一个关于Haskell类型类的问题。在GHC下,我无法调整语法以使得这个(看起来合理的)程序编译通过。
import Control.Concurrent.MVar
blah1 :: [a] -> IO ([a])
blah1 = return
blah2 :: [a] -> IO (MVar [a])
blah2 = newMVar
class Blah b where
blah :: [a] -> IO (b a)
instance Blah [] where
blah = blah1
-- BOOM
instance Blah (MVar []) where
blah = blah2
main :: IO ()
main = do
putStrLn "Ok"
我收到了以下错误信息,它有点合理,但我不知道该如何修复:
我收到了以下错误信息,它有点合理,但我不知道该如何修复:
`[]' is not applied to enough type arguments
Expected kind `*', but `[]' has kind `* -> *'
In the type `MVar []'
In the instance declaration for `Blah (MVar [])'
(.) :: (b -> c) -> (a -> b) -> a -> c
,但是对于 rank-1(或 rank-n)类型没有这样的组合。 - ephemient