refined-0.4.2.1: Refinement types with static and runtime checking

Safe HaskellSafe
LanguageHaskell2010

Refined.These

Contents

Description

This module is defined internally to avoid using the these package, which brings in a lot of very heavy and unnecessary transitive dependencies. We export the type and constructors here, in case a user should need it. We provide a small API for working with the These type here. If one should need a fuller API, see https://hackage.haskell.org/package/these Converting to/from the two types should be trivial, as the data constructors are exported from both.

Synopsis

These type

data These a b Source #

This is defined internally to avoid using the these package, which brings in a lot of very heavy and unnecessary transitive dependencies. We export the type and constructors here, in case a user should need it.

Constructors

This a 
That b 
These a b 
Instances
Bifoldable These Source # 
Instance details

Defined in Refined.These

Methods

bifold :: Monoid m => These m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> These a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> These a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> These a b -> c #

Bifunctor These Source # 
Instance details

Defined in Refined.These

Methods

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

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

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

Semigroup a => Monad (These a) Source # 
Instance details

Defined in Refined.These

Methods

(>>=) :: These a a0 -> (a0 -> These a b) -> These a b #

(>>) :: These a a0 -> These a b -> These a b #

return :: a0 -> These a a0 #

fail :: String -> These a a0 #

Functor (These a) Source # 
Instance details

Defined in Refined.These

Methods

fmap :: (a0 -> b) -> These a a0 -> These a b #

(<$) :: a0 -> These a b -> These a a0 #

Semigroup a => Applicative (These a) Source # 
Instance details

Defined in Refined.These

Methods

pure :: a0 -> These a a0 #

(<*>) :: These a (a0 -> b) -> These a a0 -> These a b #

liftA2 :: (a0 -> b -> c) -> These a a0 -> These a b -> These a c #

(*>) :: These a a0 -> These a b -> These a b #

(<*) :: These a a0 -> These a b -> These a a0 #

Foldable (These a) Source # 
Instance details

Defined in Refined.These

Methods

fold :: Monoid m => These a m -> m #

foldMap :: Monoid m => (a0 -> m) -> These a a0 -> m #

foldr :: (a0 -> b -> b) -> b -> These a a0 -> b #

foldr' :: (a0 -> b -> b) -> b -> These a a0 -> b #

foldl :: (b -> a0 -> b) -> b -> These a a0 -> b #

foldl' :: (b -> a0 -> b) -> b -> These a a0 -> b #

foldr1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> These a a0 -> a0 #

toList :: These a a0 -> [a0] #

null :: These a a0 -> Bool #

length :: These a a0 -> Int #

elem :: Eq a0 => a0 -> These a a0 -> Bool #

maximum :: Ord a0 => These a a0 -> a0 #

minimum :: Ord a0 => These a a0 -> a0 #

sum :: Num a0 => These a a0 -> a0 #

product :: Num a0 => These a a0 -> a0 #

Traversable (These a) Source # 
Instance details

Defined in Refined.These

Methods

traverse :: Applicative f => (a0 -> f b) -> These a a0 -> f (These a b) #

sequenceA :: Applicative f => These a (f a0) -> f (These a a0) #

mapM :: Monad m => (a0 -> m b) -> These a a0 -> m (These a b) #

sequence :: Monad m => These a (m a0) -> m (These a a0) #

Generic1 (These a :: Type -> Type) Source # 
Instance details

Defined in Refined.These

Associated Types

type Rep1 (These a) :: k -> Type #

Methods

from1 :: These a a0 -> Rep1 (These a) a0 #

to1 :: Rep1 (These a) a0 -> These a a0 #

(Eq a, Eq b) => Eq (These a b) Source # 
Instance details

Defined in Refined.These

Methods

(==) :: These a b -> These a b -> Bool #

(/=) :: These a b -> These a b -> Bool #

(Data a, Data b) => Data (These a b) Source # 
Instance details

Defined in Refined.These

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> These a b -> c (These a b) #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (These a b) #

toConstr :: These a b -> Constr #

dataTypeOf :: These a b -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (These a b)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (These a b)) #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> These a b -> These a b #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> These a b -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> These a b -> r #

gmapQ :: (forall d. Data d => d -> u) -> These a b -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> These a b -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> These a b -> m (These a b) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> These a b -> m (These a b) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> These a b -> m (These a b) #

(Ord a, Ord b) => Ord (These a b) Source # 
Instance details

Defined in Refined.These

Methods

compare :: These a b -> These a b -> Ordering #

(<) :: These a b -> These a b -> Bool #

(<=) :: These a b -> These a b -> Bool #

(>) :: These a b -> These a b -> Bool #

(>=) :: These a b -> These a b -> Bool #

max :: These a b -> These a b -> These a b #

min :: These a b -> These a b -> These a b #

(Read a, Read b) => Read (These a b) Source # 
Instance details

Defined in Refined.These

(Show a, Show b) => Show (These a b) Source # 
Instance details

Defined in Refined.These

Methods

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

show :: These a b -> String #

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

Generic (These a b) Source # 
Instance details

Defined in Refined.These

Associated Types

type Rep (These a b) :: Type -> Type #

Methods

from :: These a b -> Rep (These a b) x #

to :: Rep (These a b) x -> These a b #

(Semigroup a, Semigroup b) => Semigroup (These a b) Source # 
Instance details

Defined in Refined.These

Methods

(<>) :: These a b -> These a b -> These a b #

sconcat :: NonEmpty (These a b) -> These a b #

stimes :: Integral b0 => b0 -> These a b -> These a b #

(NFData a, NFData b) => NFData (These a b) Source # 
Instance details

Defined in Refined.These

Methods

rnf :: These a b -> () #

type Rep1 (These a :: Type -> Type) Source # 
Instance details

Defined in Refined.These

type Rep (These a b) Source # 
Instance details

Defined in Refined.These

Consumption

these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c Source #

Case analysis for the These type.

fromThese :: a -> b -> These a b -> (a, b) Source #

Takes two default values and produces a tuple.

mergeThese :: (a -> a -> a) -> These a a -> a Source #

Coalesce with the provided operation.

mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c Source #

BiMap and coalesce results with the provided operation.

Traversals

here :: Applicative f => (a -> f b) -> These a t -> f (These b t) Source #

A Traversal of the first half of a These, suitable for use with Control.Lens.

there :: Applicative f => (a -> f b) -> These t a -> f (These t b) Source #

A Traversal of the second half of a These, suitable for use with Control.Lens.

Case selections

justThis :: These a b -> Maybe a Source #

justThis = these Just (_ -> Nothing) (_ _ -> Nothing)

justThat :: These a b -> Maybe b Source #

justThat = these (_ -> Nothing) Just (_ _ -> Nothing)

justThese :: These a b -> Maybe (a, b) Source #

justThese = these (_ -> Nothing) (_ -> Nothing) (a b -> Just (a, b))

catThis :: [These a b] -> [a] Source #

Select all This constructors from a list.

catThat :: [These a b] -> [b] Source #

Select all That constructors from a list.

catThese :: [These a b] -> [(a, b)] Source #

Select all These constructors from a list.

partitionThese :: [These a b] -> ([(a, b)], ([a], [b])) Source #

Select each constructor and partition them into separate lists.

Case predicates

Map operations

mapThese :: (a -> c) -> (b -> d) -> These a b -> These c d Source #

mapThis :: (a -> c) -> These a b -> These c b Source #

mapThis = over here

mapThat :: (b -> d) -> These a b -> These a d Source #

mapThat = over there