tricky instance declarations

Warrick Gray oinutter@hotmail.com
Fri, 03 May 2002 22:53:00 +1200


Hi all,

I'm not very current on the latest wonders of haskell typing, but I feel 
that something like the following should be possible:

data ConnError = ...

-- error propagating monad:
instance Monad (Either ConnError) where
    (Left e) >>= _ = Left e
    (Right v) >>= f = f v
    return = Right

-- combined IO & error propagating monads
instance Monad (IO (Either ConnError a)) where
    -- (>>=) :: IO (Either ConnError a)
    --       -> (a -> IO (Either ConnError b))
    --       -> IO (Either ConnError b)
    m >>= f =  m >>= \e -> e >>= f
    return  =  return . return

I know the first declaration works with GHC compiler flag "-fglasgow-exts", 
but something about the line "Monad (IO (Either ConnError a))" makes me (and 
the compiler) very nervous.  How should I be expressing this?

Yours expectantly, Warrick.





_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx