Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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
- data These a b
- these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
- fromThese :: a -> b -> These a b -> (a, b)
- mergeThese :: (a -> a -> a) -> These a a -> a
- mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c
- here :: Applicative f => (a -> f b) -> These a t -> f (These b t)
- there :: Applicative f => (a -> f b) -> These t a -> f (These t b)
- justThis :: These a b -> Maybe a
- justThat :: These a b -> Maybe b
- justThese :: These a b -> Maybe (a, b)
- catThis :: [These a b] -> [a]
- catThat :: [These a b] -> [b]
- catThese :: [These a b] -> [(a, b)]
- partitionThese :: [These a b] -> ([(a, b)], ([a], [b]))
- isThis :: These a b -> Bool
- isThat :: These a b -> Bool
- isThese :: These a b -> Bool
- mapThese :: (a -> c) -> (b -> d) -> These a b -> These c d
- mapThis :: (a -> c) -> These a b -> These c b
- mapThat :: (b -> d) -> These a b -> These a d
These
type
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.
Instances
Bifoldable These Source # | |
Bifunctor These Source # | |
Semigroup a => Monad (These a) Source # | |
Functor (These a) Source # | |
Semigroup a => Applicative (These a) Source # | |
Foldable (These a) Source # | |
Defined in Refined.These 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] # elem :: Eq a0 => a0 -> These a a0 -> Bool # maximum :: Ord a0 => These a a0 -> a0 # minimum :: Ord a0 => These a a0 -> a0 # | |
Traversable (These a) Source # | |
Generic1 (These a :: Type -> Type) Source # | |
(Eq a, Eq b) => Eq (These a b) Source # | |
(Data a, Data b) => Data (These a b) Source # | |
Defined in Refined.These 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 # | |
Defined in Refined.These | |
(Read a, Read b) => Read (These a b) Source # | |
(Show a, Show b) => Show (These a b) Source # | |
Generic (These a b) Source # | |
(Semigroup a, Semigroup b) => Semigroup (These a b) Source # | |
(NFData a, NFData b) => NFData (These a b) Source # | |
Defined in Refined.These | |
type Rep1 (These a :: Type -> Type) Source # | |
Defined in Refined.These type Rep1 (These a :: Type -> Type) = D1 (MetaData "These" "Refined.These" "refined-0.4.4-7xXnhN9HJ7XByi1PQY08Xe" False) (C1 (MetaCons "This" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :+: (C1 (MetaCons "That" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1) :+: C1 (MetaCons "These" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))) | |
type Rep (These a b) Source # | |
Defined in Refined.These type Rep (These a b) = D1 (MetaData "These" "Refined.These" "refined-0.4.4-7xXnhN9HJ7XByi1PQY08Xe" False) (C1 (MetaCons "This" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :+: (C1 (MetaCons "That" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 b)) :+: C1 (MetaCons "These" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 b)))) |
Consumption
these :: (a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c Source #
Case analysis for the These
type.
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
partitionThese :: [These a b] -> ([(a, b)], ([a], [b])) Source #
Select each constructor and partition them into separate lists.