initial commit

This commit is contained in:
Stephen Diehl
2016-04-07 15:22:44 -04:00
commit 29b854cf98
15 changed files with 656 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
module Applicative (
orAlt,
orEmpty,
eitherA,
) where
import Data.Monoid
import Control.Applicative
import Prelude (Bool, Either(..))
orAlt :: (Alternative f, Monoid a) => f a -> f a
orAlt f = f <|> pure mempty
orEmpty :: Alternative f => Bool -> a -> f a
orEmpty b a = if b then pure a else empty
eitherA :: (Alternative f) => f a -> f b -> f (Either a b)
eitherA a b = (Left <$> a) <|> (Right <$> b)