mirror of
https://github.com/byteverse/colonnade.git
synced 2024-09-11 06:45:41 +03:00
Added Internal module
This commit is contained in:
parent
edefcb6953
commit
5f9e4f6416
@ -18,6 +18,7 @@ library
|
||||
Colonnade.Types
|
||||
Colonnade.Encoding
|
||||
Colonnade.Decoding
|
||||
Colonnade.Internal
|
||||
Colonnade.Internal.Ap
|
||||
build-depends:
|
||||
base >= 4.7 && < 5
|
||||
|
14
colonnade/src/Colonnade/Internal.hs
Normal file
14
colonnade/src/Colonnade/Internal.hs
Normal 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))
|
||||
|
Loading…
Reference in New Issue
Block a user