Data.Extensible

Contents

Synopsis

# Lookup

data Position x xs Source

Instances

 Show (Position k k x xs)

class x xs where Source

Methods

position :: Position x xs Source

Instances

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

# Product

data h :* s where Source

The extensible product type

Constructors

 Nil :: h :* [] Tree :: h x -> (h :* Half xs) -> (h :* Half (Tail xs)) -> h :* (x : xs)

Instances

 (Show ((:*) k h xs), Show (h x)) => Show ((:*) k h ((:) k x xs)) Show ((:*) k h ([] k))

(<:*) :: h x -> (h :* xs) -> h :* (x : xs) infixr 5 Source

O(log n) Add an element to a product.

unconsP :: (h :* (x : xs)) -> (h x, h :* xs) Source

outP :: forall h x xs. x xs => (h :* xs) -> h x Source

O(log n) Pick a specific element.

record :: forall h x xs f. (Functor f, x xs) => (h x -> f (h x)) -> (h :* xs) -> f (h :* xs) Source

O(log n) A lens for a specific element.

recordAt :: forall h x xs f. Functor f => Position x xs -> (h x -> f (h x)) -> (h :* xs) -> f (h :* xs) Source

# Sum

data h :| s where Source

The extensible sum type

Constructors

 UnionAt :: Position x xs -> h x -> h :| xs

Instances

 (Show (h x), Show ((:|) k h xs)) => Show ((:|) k h ((:) k x xs)) Show ((:|) k h ([] k))

(<:|) :: (h x -> r) -> ((h :| xs) -> r) -> (h :| (x : xs)) -> r Source

O(n) Naive pattern match

exhaust :: (h :| []) -> r Source

inS :: x xs => h x -> h :| xs Source

O(log n)

# Utilities

newtype K0 a Source

Constructors

 K0 FieldsgetK0 :: a

Instances

 Eq a => Eq (K0 a) Ord a => Ord (K0 a) Read a => Read (K0 a) Show a => Show (K0 a) Typeable (* -> *) K0

platter :: (x xs, Functor f) => (x -> f x) -> (K0 :* xs) -> f (K0 :* xs) Source

O(log n) A lens for a plain value in a product.

(<%) :: x -> (K0 :* xs) -> K0 :* (x : xs) infixr 5 Source

O(log n) Add a plain value to a product.

newtype K1 a f Source

Constructors

 K1 FieldsgetK1 :: f a

Instances

 Typeable (k -> (k -> *) -> *) (K1 k) Eq (f a) => Eq (K1 k a f) Ord (f a) => Ord (K1 k a f) Read (f a) => Read (K1 k a f) Show (f a) => Show (K1 k a f)

newtype Union fs a Source

Constructors

 Union FieldsgetUnion :: K1 a :| fs

Instances

 Show ((:|) (k -> *) (K1 k a) fs) => Show (Union k fs a)

liftU :: f fs => f a -> Union fs a Source

newtype Match h a x Source

Constructors

 Match FieldsrunMatch :: h x -> a

match :: (Match h a :* xs) -> (h :| xs) -> a Source

O(log n) Perform pattern match.

(<?%) :: (x -> a) -> (Match K0 a :* xs) -> Match K0 a :* (x : xs) infixr 1 Source

(<?!) :: (f x -> a) -> (Match (K1 x) a :* xs) -> Match (K1 x) a :* (f : fs) infixr 1 Source