extensible-0.2.2: Poly-kinded, extensible ADTs

Safe HaskellNone
LanguageHaskell2010

Data.Extensible.Internal

Synopsis

Documentation

data Position xs x Source

The position of x in the type level set xs.

Instances

Typeable ([k] -> k -> *) (Position k) 
Eq (Position k xs x) 
Ord (Position k xs x) 
Show (Position k xs x) 

runPosition :: Position (y : xs) x -> Either (x :~: y) (Position xs x) Source

Embodies a type equivalence to ensure that the Position points the first element.

comparePosition :: Position xs x -> Position xs y -> Maybe (x :~: y) Source

data Nav xs x where Source

Constructors

Here :: Nav (x : xs) x 
NavL :: Position (Half xs) x -> Nav (e : xs) x 
NavR :: Position (Half (Tail xs)) x -> Nav (e : xs) x 

navigate :: Position xs x -> Nav xs x Source

here :: Position (x : xs) x Source

navL :: Position (Half xs) y -> Position (x : xs) y Source

navR :: Position (Half (Tail xs)) y -> Position (x : xs) y Source

class Member xs x where Source

Member x xs or x ∈ xs indicates that x is an element of xs.

Methods

membership :: Position xs x Source

Instances

Record Nat (Lookup k x xs) => Member k xs x 

type (∈) x xs = Member xs x Source

Unicode flipped alias for Member

data Nat Source

Constructors

Zero 
DNat Nat 
SDNat Nat 
NotFound 

Instances

class Record n where Source

Methods

theInt :: Proxy n -> Int Source

Instances

type family Lookup x xs :: Nat Source

Equations

Lookup x (x : xs) = Zero 
Lookup x (y : ys) = Succ (Lookup x ys) 
Lookup x [] = NotFound 

type family Succ x :: Nat Source

Equations

Succ Zero = SDNat Zero 
Succ (DNat n) = SDNat n 
Succ (SDNat n) = DNat (Succ n) 
Succ NotFound = NotFound 

type family Half xs :: [k] Source

Equations

Half [] = [] 
Half (x : (y : zs)) = x : zs 
Half (x : []) = x : [] 

type family Tail xs :: [k] Source

Equations

Tail (x : xs) = xs 
Tail [] = [] 

lemmaHalfTail :: Proxy xs -> p (x : Half (Tail xs)) -> p (Half (x : xs)) Source