Brian Smith wrote:

[...]

> instance MonadError (Either ReferenceError)

Kind error: `Either ReferenceError' is not applied to enough type arguments
When checking kinds in `MonadError (Either ReferenceError)'
In the instance declaration for `MonadError (Either ReferenceError)'


MonadError takes two parameters: the error type (with kind *) and the monad (with kind *->*). So:

   instance MonadError ReferenceError (Either ReferenceError)

Unfortunately this takes you into the realm of Overlapping Instances. I recommend that you instead extend ReferenceError so that it /can/ be made an instance of Error:

   data ReferenceError = {- what you already had -} | NonRefError String

...and bear in mind that NonRefError will only occur when the fail method or the mzero method is used, which won't happen much if you consistently use throwError instead. It sometimes helps to define a function which catches one sort of error and lets others through:

   -- untested
   m `onRefError` h
       = m `catchError` \e ->
         case e of
             RefError{} -> h (expectedType e) (pointOfError e)
             _          -> throwError e

HTH.
Tom


_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to