Haskell typeclass
- by Geoff
I have a Haskell typeclass question. I can't munge the syntax to get this (seemingly reasonable) program to compile under 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"
I get the following error message, which kind of makes sense, but I don't know how to fix it:
`[]' is not applied to enough type arguments
Expected kind `*', but `[]' has kind `* -> *'
In the type `MVar []'
In the instance declaration for `Blah (MVar [])'