[Haskell-cafe] instance monad problem

Veer Singh haskellnew at gmail.com
Mon May 14 16:53:03 EDT 2007


Hello,
I am trying to learn haskell , but i am struggling with types  , its
been around 7 days , it will be very kind if some explain it why this
error , i think this is the only stumbling block . I am looking for
the comparison on why similar code works , while other code not .


I get this error on ghci  :
{-
 `a' is not applied to enough type arguments
    Expected kind `*', but `a' has kind `* -> *'
    In the type `SS a'
    In the type `(Monad a) => {Monad (SS a)}'
    In the instance declaration for `Monad (SS a)'
-}


Here is the very small code with comments:


data SS a = SS a Int
data Maybe1 a = Nothing1 | Just1 a

instance Monad Maybe1  where
  (Just1 x) >>= f = f x

--^^ this loads fine in ghci

-- where as this
instance (Monad a)=> Monad (SS a) where
  (SS x y) >>= f = f (x y)

--^^ does not work , so whats the difference , both have type parameters

-- something similar works like this :
instance (Eq a)=>Eq (SS a) where
  (SS x y)  == (SS b c) = (y == c) && (x == b)

Thanks


More information about the Haskell-Cafe mailing list