Haskell typeclass
Posted
by Geoff
on Stack Overflow
See other posts from Stack Overflow
or by Geoff
Published on 2009-12-01T17:21:39Z
Indexed on
2010/03/21
5:31 UTC
Read the original article
Hit count: 406
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 [])'
© Stack Overflow or respective owner