[Haskell-beginners] Maybe, Either

Michael Mossey mpm at alumni.caltech.edu
Sat Sep 12 11:14:28 EDT 2009


I want to use 'lookup' inside an Either String monad. So I want to write 
something like

eitherLookup :: Eq a => String -> a -> [(a,b)] -> Either String b
eitherLookup s x ps = case lookup x ps of
                          Just y -> Right y
                          Nothing -> Left s

Is there such a function existing?

Thanks,
Mike


More information about the Beginners mailing list