jordan-0.2.0.0: JSON with Structure
Safe HaskellSafe-Inferred
LanguageHaskell2010

Jordan.Types.Internal.AccumE

Description

Either, but with an Applicative instance that combines errors via <>.

This is sometimes known as the validation Applicative. There are Haskell packages providing this type, however, in the interest of minimized dependency footprint we use this.

Synopsis

Documentation

newtype AccumE err val Source #

A version of Either that accumulates errors via an instance of Semigroup.

This is sometimes called the validation applicative.

Constructors

AccumE 

Fields

Bundled Patterns

pattern AccumEL :: err -> AccumE err val

Construct an error value.

pattern AccumER :: val -> AccumE err val

Construct a good value. Equivalent to pure.

Instances

Instances details
Bifunctor AccumE Source # 
Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

bimap :: (a -> b) -> (c -> d) -> AccumE a c -> AccumE b d #

first :: (a -> b) -> AccumE a c -> AccumE b c #

second :: (b -> c) -> AccumE a b -> AccumE a c #

Functor (AccumE err) Source # 
Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

fmap :: (a -> b) -> AccumE err a -> AccumE err b #

(<$) :: a -> AccumE err b -> AccumE err a #

Semigroup e => Applicative (AccumE e) Source #

Applicative accumulates errors.

Note that this is *strict* in the error, because this can sometimes reduce the number of allocations in the places where we use this.

Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

pure :: a -> AccumE e a #

(<*>) :: AccumE e (a -> b) -> AccumE e a -> AccumE e b #

liftA2 :: (a -> b -> c) -> AccumE e a -> AccumE e b -> AccumE e c #

(*>) :: AccumE e a -> AccumE e b -> AccumE e b #

(<*) :: AccumE e a -> AccumE e b -> AccumE e a #

Monoid m => Alternative (AccumE m) Source #

Alternative takes the first result if there is a result. If there is not, will *not* accumulate errors.

Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

empty :: AccumE m a #

(<|>) :: AccumE m a -> AccumE m a -> AccumE m a #

some :: AccumE m a -> AccumE m [a] #

many :: AccumE m a -> AccumE m [a] #

(Read a, Read b) => Read (AccumE a b) Source #

Read instance uses the AccumER and AccumEL pattern synonyms.

Instance details

Defined in Jordan.Types.Internal.AccumE

(Show a, Show b) => Show (AccumE a b) Source #

Show instance uses the AccumER and AccumEL pattern synonyms.

Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

showsPrec :: Int -> AccumE a b -> ShowS #

show :: AccumE a b -> String #

showList :: [AccumE a b] -> ShowS #

Generic (AccumE err val) Source # 
Instance details

Defined in Jordan.Types.Internal.AccumE

Associated Types

type Rep (AccumE err val) :: Type -> Type #

Methods

from :: AccumE err val -> Rep (AccumE err val) x #

to :: Rep (AccumE err val) x -> AccumE err val #

Semigroup e => Semigroup (AccumE e a) Source #

Semigroup accumulates errors if both are errors, otherwise it returns the first good value.

Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

(<>) :: AccumE e a -> AccumE e a -> AccumE e a #

sconcat :: NonEmpty (AccumE e a) -> AccumE e a #

stimes :: Integral b => b -> AccumE e a -> AccumE e a #

Monoid err => Monoid (AccumE err a) Source # 
Instance details

Defined in Jordan.Types.Internal.AccumE

Methods

mempty :: AccumE err a #

mappend :: AccumE err a -> AccumE err a -> AccumE err a #

mconcat :: [AccumE err a] -> AccumE err a #

type Rep (AccumE err val) Source # 
Instance details

Defined in Jordan.Types.Internal.AccumE

type Rep (AccumE err val) = D1 ('MetaData "AccumE" "Jordan.Types.Internal.AccumE" "jordan-0.2.0.0-inplace" 'True) (C1 ('MetaCons "AccumE" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAccumE") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either err val))))