type-combinators-0.2.4.3: A collection of data types for type-level programming

CopyrightCopyright (C) 2015 Kyle Carter
LicenseBSD3
MaintainerKyle Carter <kylcarte@indiana.edu>
Stabilityexperimental
PortabilityRankNTypes
Safe HaskellNone
LanguageHaskell2010

Type.Family.Either

Description

Convenient type families for working with type-level Eithers.

Synopsis

Documentation

type family EitherC (ec :: Either k Constraint) :: Constraint where ... Source #

Take a Maybe Constraint to a Constraint.

Equations

EitherC (Left a) = ØC 
EitherC (Right c) = c 

type family IsLeft (a :: Either k l) :: Bool where ... Source #

Equations

IsLeft (Left a) = True 
IsLeft (Right b) = False 

type family IsRight (a :: Either k l) :: Bool where ... Source #

Equations

IsRight (Left a) = False 
IsRight (Right b) = True 

leftCong :: (a ~ b) :- (IsLeft a ~ IsLeft b) Source #

rightCong :: (a ~ b) :- (IsRight a ~ IsRight b) Source #

type family (f :: k -> l) <$> (a :: Either m k) :: Either m l where ... infixr 4 Source #

Map over a type-level Maybe.

Equations

f <$> (Left a) = Left a 
f <$> (Right b) = Right (f b) 

eitherFmapCong :: (f ~ g, a ~ b) :- ((f <$> a) ~ (g <$> b)) Source #

type family (f :: Either m (k -> l)) <&> (a :: k) :: Either m l where ... infixl 5 Source #

Equations

(Left x) <&> a = Left x 
(Right f) <&> a = Right (f a) 

eitherPamfCong :: (f ~ g, a ~ b) :- ((f <&> a) ~ (g <&> b)) Source #

type family (f :: Either m (k -> l)) <*> (a :: Either m k) :: Either m l where ... infixr 4 Source #

Equations

(Left x) <*> (Left y) = Left (x <> y) 
(Left x) <*> a = Left x 
f <*> (Left x) = Left x 
(Right f) <*> (Right a) = Right (f a) 

eitherApCong :: (f ~ g, a ~ b) :- ((f <*> a) ~ (g <*> b)) Source #

type family (a :: Either m k) <|> (b :: Either m k) :: Either m k where ... infixr 4 Source #

Equations

(Left x) <|> b = b 
(Right a) <|> b = Right a 

eitherAltCong :: (a ~ c, b ~ d) :- ((a <|> b) ~ (c <|> d)) Source #

type family FromLeft (e :: Either k l) :: k where ... Source #

Equations

FromLeft (Left a) = a 

type family FromRight (e :: Either k l) :: l where ... Source #

Equations

FromRight (Right b) = b