<|> Alternative Control.Applicative. Maybe :
Just a <|> _ = Just a
Nothing <|> Just a = Just a
Nothing <|> Nothing = Nothing
, x || x == x . :
orMaybe a b = liftA2 (||) (a <|> b) (b <|> a) <|> Just False
a b Just x, liftA2 (||) Just (a || b). Nothing, (a <|> b) (b <|> a) a, b, Just (a || a) Just (b || b). , Nothing, liftA2 (||) Nothing Nothing, Nothing. <|> Just False Just False.
, , . ? ! Maybe Nothing ; , .
Note: liftA2comes from Control.Applicative. It's just like liftMthat, but for applications; I used it to match with <|>. You could use fmap.
source
share