Added Internal module

This commit is contained in:
Andrew Martin 2016-06-23 19:01:43 -04:00
parent edefcb6953
commit 5f9e4f6416
2 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,7 @@ library
Colonnade.Types
Colonnade.Encoding
Colonnade.Decoding
Colonnade.Internal
Colonnade.Internal.Ap
build-depends:
base >= 4.7 && < 5

View File

@ -0,0 +1,14 @@
{-# LANGUAGE DeriveFunctor #-}
module Colonnade.Internal where
newtype EitherWrap a b = EitherWrap
{ getEitherWrap :: Either a b
} deriving (Functor)
instance Monoid a => Applicative (EitherWrap a) where
pure = EitherWrap . Right
EitherWrap (Left a1) <*> EitherWrap (Left a2) = EitherWrap (Left (mappend a1 a2))
EitherWrap (Left a1) <*> EitherWrap (Right _) = EitherWrap (Left a1)
EitherWrap (Right _) <*> EitherWrap (Left a2) = EitherWrap (Left a2)
EitherWrap (Right f) <*> EitherWrap (Right b) = EitherWrap (Right (f b))