Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Dichotomous (f :: Type -> Type -> Type) where
- hushLeft :: Dichotomous g => g l r -> Maybe r
- hushRight :: Dichotomous g => g l r -> Maybe l
- swap :: Dichotomous g => g a b -> Maybe (g b a)
- newtype AltSum f a = AltSum {
- unAltSum :: f a
- mfold' :: (Foldable f, Alternative m) => f a -> m a
- mlefts :: (Bifoldable f, Alternative m) => f a b -> m a
- mrights :: (Bifoldable f, Alternative m) => f a b -> m b
- flipThese :: These a b -> These b a
- newtype LeftOnly a b = LeftOnly {
- unLeftOnly :: a
- data LeftOrBoth a b
- newtype RightOnly a b = RightOnly {
- unRightOnly :: b
- data RightOrBoth a b
- data These a b
- data None a b = None
- newtype MaybeBoth a b = MaybeBoth {
- unMaybeOrBoth :: Maybe (a, b)
- data MaybeRight a b
- data MaybeRightOrBoth a b
- = MRBNothing
- | MRBRight b
- | MRBoth a b
- data MaybeLeft a b
- data MaybeLeftOrBoth a b
- = MLBNothing
- | MLBLeft a
- | MLBoth a b
- data MaybeEither a b
- data TheseOrNot a b
Documentation
class Dichotomous (f :: Type -> Type -> Type) where Source #
Dichotomous is about types that are injective to (Maybe (These a b)) In other words a + b + (a * b) + 1. Therefore ab (,) b LeftOnly b ab LeftOrBoth a RightOnly a ab RightOrBoth a b Either a b ab These 1 None 1 ab MaybeBoth 1 b MaybeRight 1 b ab MaybeRightOrBoth 1 a MaybeLeft 1 a ab MaybeLeftOrBoth 1 a b MaybeEither 1 a b ab TheseOrNot
Instances
hushLeft :: Dichotomous g => g l r -> Maybe r Source #
hushRight :: Dichotomous g => g l r -> Maybe l Source #
swap :: Dichotomous g => g a b -> Maybe (g b a) Source #
Instances
Functor f => Functor (AltSum f) Source # | |
Applicative f => Applicative (AltSum f) Source # | |
Alternative f => Alternative (AltSum f) Source # | |
Alternative f => Semigroup (AltSum f a) Source # | |
Alternative f => Monoid (AltSum f a) Source # | |
mfold' :: (Foldable f, Alternative m) => f a -> m a Source #
mlefts :: (Bifoldable f, Alternative m) => f a b -> m a Source #
mrights :: (Bifoldable f, Alternative m) => f a b -> m b Source #
LeftOnly | |
|
Instances
Dichotomous LeftOnly Source # | |
Eq a => Eq (LeftOnly a b) Source # | |
Ord a => Ord (LeftOnly a b) Source # | |
Defined in Control.Functor.Dichotomous | |
Read a => Read (LeftOnly a b) Source # | |
Show a => Show (LeftOnly a b) Source # | |
Generic (LeftOnly a b) Source # | |
type Rep (LeftOnly a b) Source # | |
Defined in Control.Functor.Dichotomous |
data LeftOrBoth a b Source #
Instances
newtype RightOnly a b Source #
RightOnly | |
|
Instances
Dichotomous RightOnly Source # | |
Eq b => Eq (RightOnly a b) Source # | |
Ord b => Ord (RightOnly a b) Source # | |
Defined in Control.Functor.Dichotomous compare :: RightOnly a b -> RightOnly a b -> Ordering # (<) :: RightOnly a b -> RightOnly a b -> Bool # (<=) :: RightOnly a b -> RightOnly a b -> Bool # (>) :: RightOnly a b -> RightOnly a b -> Bool # (>=) :: RightOnly a b -> RightOnly a b -> Bool # | |
Read b => Read (RightOnly a b) Source # | |
Show b => Show (RightOnly a b) Source # | |
Generic (RightOnly a b) Source # | |
type Rep (RightOnly a b) Source # | |
Defined in Control.Functor.Dichotomous |
data RightOrBoth a b Source #
Instances
The These
type represents values with two non-exclusive possibilities.
This can be useful to represent combinations of two values, where the
combination is defined if either input is. Algebraically, the type
represents These
A B(A + B + AB)
, which doesn't factor easily into
sums and products--a type like
is unclear and
awkward to use.Either
A (B, Maybe
A)
These
has straightforward instances of Functor
, Monad
, &c., and
behaves like a hybrid error/writer monad, as would be expected.
For zipping and unzipping of structures with These
values, see
Data.Align.
Instances
Bifunctor These | |
Swap These | Since: these-0.8 |
Defined in Data.These | |
Assoc These | Since: these-0.8 |
Bitraversable These | |
Defined in Data.These bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> These a b -> f (These c d) # | |
Bifoldable These | |
Eq2 These | Since: these-1.1.1 |
Ord2 These | Since: these-1.1.1 |
Defined in Data.These | |
Read2 These | Since: these-1.1.1 |
Defined in Data.These liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (These a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [These a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (These a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [These a b] # | |
Show2 These | Since: these-1.1.1 |
NFData2 These | Since: these-1.1.1 |
Defined in Data.These | |
Hashable2 These | Since: these-1.1.1 |
Defined in Data.These | |
Dichotomous These Source # | |
Semigroup a => Monad (These a) | |
Functor (These a) | |
Semigroup a => Applicative (These a) | |
Foldable (These a) | |
Defined in Data.These fold :: Monoid m => These a m -> m # foldMap :: Monoid m => (a0 -> m) -> These a a0 -> 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) | |
Eq a => Eq1 (These a) | Since: these-1.1.1 |
Ord a => Ord1 (These a) | Since: these-1.1.1 |
Defined in Data.These | |
Read a => Read1 (These a) | Since: these-1.1.1 |
Defined in Data.These | |
Show a => Show1 (These a) | Since: these-1.1.1 |
NFData a => NFData1 (These a) | Since: these-1.1.1 |
Defined in Data.These | |
Hashable a => Hashable1 (These a) | Since: these-1.1.1 |
Defined in Data.These | |
Monoid m => Compactable (These m) Source # | |
Defined in Control.Functor.Compactable compact :: These m (Maybe a) -> These m a Source # separateThese :: These m (These l r) -> (These m l, These m r) Source # filter :: (a -> Bool) -> These m a -> These m a Source # partition :: (a -> Bool) -> These m a -> (These m a, These m a) Source # mapMaybe :: Functor (These m) => (a -> Maybe b) -> These m a -> These m b Source # contramapMaybe :: Contravariant (These m) => (Maybe b -> a) -> These m a -> These m b Source # mapThese :: Functor (These m) => (a -> These l r) -> These m a -> (These m l, These m r) Source # contramapThese :: Contravariant (These m) => (These l r -> a) -> These m a -> (These m l, These m r) Source # applyMaybe :: Applicative (These m) => These m (a -> Maybe b) -> These m a -> These m b Source # applyThese :: Applicative (These m) => These m (a -> These l r) -> These m a -> (These m l, These m r) Source # bindMaybe :: Monad (These m) => (a -> These m (Maybe b)) -> These m a -> These m b Source # bindThese :: Monad (These m) => (a -> These m (These l r)) -> These m a -> (These m l, These m r) Source # traverseMaybe :: (Applicative g, Traversable (These m)) => (a -> g (Maybe b)) -> These m a -> g (These m b) Source # traverseThese :: (Applicative g, Traversable (These m)) => (a -> g (These l r)) -> These m a -> g (These m l, These m r) Source # | |
Generic1 (These a :: Type -> Type) | |
(Eq a, Eq b) => Eq (These a b) | |
(Data a, Data b) => Data (These a b) | |
Defined in Data.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 :: forall r r'. (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) | |
Defined in Data.These | |
(Read a, Read b) => Read (These a b) | |
(Show a, Show b) => Show (These a b) | |
Generic (These a b) | |
(Semigroup a, Semigroup b) => Semigroup (These a b) | |
(Hashable a, Hashable b) => Hashable (These a b) | |
Defined in Data.These | |
(Binary a, Binary b) => Binary (These a b) | Since: these-0.7.1 |
(NFData a, NFData b) => NFData (These a b) | Since: these-0.7.1 |
Defined in Data.These | |
type Rep1 (These a :: Type -> Type) | |
Defined in Data.These type Rep1 (These a :: Type -> Type) = D1 ('MetaData "These" "Data.These" "these-1.1.1.1-HvJGKxaeYPR1jVMtgZOtPT" '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) | |
Defined in Data.These type Rep (These a b) = D1 ('MetaData "These" "Data.These" "these-1.1.1.1-HvJGKxaeYPR1jVMtgZOtPT" '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)))) |
newtype MaybeBoth a b Source #
MaybeBoth | |
|
Instances
Dichotomous MaybeBoth Source # | |
(Eq a, Eq b) => Eq (MaybeBoth a b) Source # | |
(Ord a, Ord b) => Ord (MaybeBoth a b) Source # | |
Defined in Control.Functor.Dichotomous compare :: MaybeBoth a b -> MaybeBoth a b -> Ordering # (<) :: MaybeBoth a b -> MaybeBoth a b -> Bool # (<=) :: MaybeBoth a b -> MaybeBoth a b -> Bool # (>) :: MaybeBoth a b -> MaybeBoth a b -> Bool # (>=) :: MaybeBoth a b -> MaybeBoth a b -> Bool # | |
(Read a, Read b) => Read (MaybeBoth a b) Source # | |
(Show a, Show b) => Show (MaybeBoth a b) Source # | |
Generic (MaybeBoth a b) Source # | |
type Rep (MaybeBoth a b) Source # | |
Defined in Control.Functor.Dichotomous |
data MaybeRight a b Source #
Instances
data MaybeRightOrBoth a b Source #
MRBNothing | |
MRBRight b | |
MRBoth a b |
Instances
Instances
Dichotomous MaybeLeft Source # | |
Eq a => Eq (MaybeLeft a b) Source # | |
Ord a => Ord (MaybeLeft a b) Source # | |
Defined in Control.Functor.Dichotomous compare :: MaybeLeft a b -> MaybeLeft a b -> Ordering # (<) :: MaybeLeft a b -> MaybeLeft a b -> Bool # (<=) :: MaybeLeft a b -> MaybeLeft a b -> Bool # (>) :: MaybeLeft a b -> MaybeLeft a b -> Bool # (>=) :: MaybeLeft a b -> MaybeLeft a b -> Bool # | |
Read a => Read (MaybeLeft a b) Source # | |
Show a => Show (MaybeLeft a b) Source # | |
Generic (MaybeLeft a b) Source # | |
type Rep (MaybeLeft a b) Source # | |
Defined in Control.Functor.Dichotomous type Rep (MaybeLeft a b) = D1 ('MetaData "MaybeLeft" "Control.Functor.Dichotomous" "compactable-0.2.0.0-5KI6UAYCQgl1RWEyoYfh9X" 'False) (C1 ('MetaCons "MLNothing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MLeft" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
data MaybeLeftOrBoth a b Source #
MLBNothing | |
MLBLeft a | |
MLBoth a b |
Instances
data MaybeEither a b Source #
Instances
data TheseOrNot a b Source #