singletons-0.10.0: A framework for generating singleton types

Copyright(C) 2013 Richard Eisenberg
LicenseBSD-style (see LICENSE)
MaintainerRichard Eisenberg (eir@cis.upenn.edu)
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Singletons.Either

Contents

Description

Defines functions and datatypes relating to the singleton for Either, including a singletons version of all the definitions in Data.Either.

Because many of these definitions are produced by Template Haskell, it is not possible to create proper Haddock documentation. Please look up the corresponding operation in Data.Either. Also, please excuse the apparent repeated variable names. This is due to an interaction between Template Haskell and Haddock.

Synopsis

The Either singleton

data family Sing a Source

The singleton kind-indexed data family.

Instances

TestCoercion * (Sing *) 
SDecide k (KProxy k) => TestEquality k (Sing k) 
data Sing Bool where 
data Sing Ordering where 
data Sing * where 
data Sing Nat where 
data Sing Symbol where 
data Sing () where 
data Sing [a0] where 
data Sing (Maybe a0) where 
data Sing (Either a0 b0) where 
data Sing ((,) a0 b0) where 
data Sing ((,,) a0 b0 c0) where 
data Sing ((,,,) a0 b0 c0 d0) where 
data Sing ((,,,,) a0 b0 c0 d0 e0) where 
data Sing ((,,,,,) a0 b0 c0 d0 e0 f0) where 
data Sing ((,,,,,,) a0 b0 c0 d0 e0 f0 g0) where 

Though Haddock doesn't show it, the Sing instance above declares constructors

SLeft  :: Sing a -> Sing (Left a)
SRight :: Sing b -> Sing (Right b)

type SEither z = Sing z Source

SEither is a kind-restricted synonym for Sing: type SEither (a :: Either x y) = Sing a

Singletons from Data.Either

type family Either_ a a a :: c Source

Equations

Either_ f z (Left x) = f x 
Either_ z g (Right y) = g y 

sEither_ :: forall t t t. (forall t. Sing t -> Sing (t t)) -> (forall t. Sing t -> Sing (t t)) -> Sing t -> Sing (Either_ t t t) Source

The preceding two definitions are derived from the function either in Data.Either. The extra underscore is to avoid name clashes with the type Either.

type family Lefts a :: [a] Source

Equations

Lefts [] = `[]` 
Lefts ((:) (Left x) xs) = (:) x (Lefts xs) 
Lefts ((:) (Right z) xs) = Lefts xs 

sLefts :: forall t. Sing t -> Sing (Lefts t) Source

type family Rights a :: [b] Source

Equations

Rights [] = `[]` 
Rights ((:) (Left z) xs) = Rights xs 
Rights ((:) (Right x) xs) = (:) x (Rights xs) 

sRights :: forall t. Sing t -> Sing (Rights t) Source

type family PartitionEithers a :: ([a], [b]) Source

Equations

PartitionEithers es = PartitionEithers_aux `(`[]`, `[]`)` es 

type family IsLeft a :: Bool Source

Equations

IsLeft (Left z) = True 
IsLeft (Right z) = False 

sIsLeft :: forall t. Sing t -> Sing (IsLeft t) Source

type family IsRight a :: Bool Source

Equations

IsRight (Left z) = False 
IsRight (Right z) = True 

sIsRight :: forall t. Sing t -> Sing (IsRight t) Source