mirror of
https://github.com/byteverse/colonnade.git
synced 2026-04-21 07:27:44 +02:00
Added Internal module
This commit is contained in:
parent
edefcb6953
commit
5f9e4f6416
@ -18,6 +18,7 @@ library
|
|||||||
Colonnade.Types
|
Colonnade.Types
|
||||||
Colonnade.Encoding
|
Colonnade.Encoding
|
||||||
Colonnade.Decoding
|
Colonnade.Decoding
|
||||||
|
Colonnade.Internal
|
||||||
Colonnade.Internal.Ap
|
Colonnade.Internal.Ap
|
||||||
build-depends:
|
build-depends:
|
||||||
base >= 4.7 && < 5
|
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