Re: [Haskell-cafe] Missing a "Deriving"?
Got it. Thanks! Michael --- On Mon, 6/1/09, Daniel Fischer <daniel.is.fischer@web.de> wrote: From: Daniel Fischer <daniel.is.fischer@web.de> Subject: Re: [Haskell-cafe] Missing a "Deriving"? To: haskell-cafe@haskell.org Date: Monday, June 1, 2009, 1:51 PM Am Montag 01 Juni 2009 19:02:36 schrieb michael rice:
All good so far, but then tried to convert Failable from Computation to Monad
instance Monad Failable where return = Success fail = Fail >>= (Success x) f = f x >>= (Fail s) _ = Fail s mplus (Fail _) y = y mplus x _ = x
and got the following error.
Prelude> :l graph5 [1 of 1] Compiling Main ( graph5.hs, interpreted )
graph5.hs:34:4: parse error on input `>>=' Failed, modules loaded: none. Prelude>
When you use an operator in prefix position, you must enclose it in parentheses, like you must enclose a function in backticks if you use it infix. So the definition of (>>=) should read (>>=) (Success x) f = f x (>>=) (Fail s) _ = Fail s or, defining it in infix position, (Success x) >>= f = f x (Fail s) >>= _ = Fail s
Complete code follows.
Michael
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (1)
-
michael rice