Skip to content
Snippets Groups Projects
Commit a9ccc950 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a Functor instance for our Result type


This will allow us to use the simpler applicative form (<$>, <*>)
instead of monadic liftM, liftM2, etc.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent be747966
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,10 @@ instance Monad Result where
return = Ok
fail = Bad
instance Functor Result where
fmap _ (Bad msg) = Bad msg
fmap fn (Ok val) = Ok (fn val)
instance MonadPlus Result where
mzero = Bad "zero Result when used as MonadPlus"
-- for mplus, when we 'add' two Bad values, we concatenate their
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment