extensible-0.3.5: Extensible, efficient, lens-friendly data types

Copyright(c) Fumiaki Kinoshita 2015
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Stabilityexperimental
PortabilityMPTCs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Extensible.Class

Contents

Description

 

Synopsis

Class

class (Functor f, Profunctor p) => Extensible f p t where Source

This class allows us to use pieceAt for both sums and products.

Methods

pieceAt :: Membership xs x -> Optic' p f (t h xs) (h x) Source

Instances

Functor f => Extensible k f (->) ((:*) k) 
(Applicative f, Choice p) => Extensible k f p ((:|) k) 
(Functor f, Profunctor p) => Extensible k f p (Inextensible k) 

piece :: (x xs, Extensible f p t) => Optic' p f (t h xs) (h x) Source

Accessor for an element.

pieceAssoc :: (Associate k v xs, Extensible f p t) => Optic' p f (t h xs) (h (k :> v)) Source

Like piece, but reckon membership from its key.

itemAt :: (Wrapper h, Extensible f p t) => Membership xs x -> Optic' p f (t h xs) (Repr h x) Source

item :: (Wrapper h, Extensible f p t, x xs) => proxy x -> Optic' p f (t h xs) (Repr h x) Source

itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v)) Source

Membership

data Membership xs x Source

The position of x in the type level set xs.

Instances

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

mkMembership :: Int -> Q Exp Source

Generates a Membership that corresponds to the given ordinal (0-origin).

Member

class Member xs x where Source

Instances

((~) (Elaborated k Nat) (Elaborate k Nat x (FindType k x xs)) (Expecting k Nat pos), KnownPosition Nat pos) => Member k xs x 

remember :: forall xs x r. Membership xs x -> (Member xs x => r) -> r Source

Remember that Member xs x from Membership.

type (∈) x xs = Member xs x Source

Unicode flipped alias for Member

type family FindType x xs :: [Nat] Source

FindType types

Equations

FindType x (x : xs) = Zero : FindType x xs 
FindType x (y : ys) = MapSucc (FindType x ys) 
FindType x [] = [] 

Association

data Assoc k v Source

The kind of key-value pairs

Constructors

k :> v infix 0 

Instances

Associate k k1 k2 v xs => Associated (Assoc k k) xs ((:>) k k k v) 
Wrapper k h => Wrapper (Assoc k k) (Field k k h) 
type Repr (Assoc k1 k) (Field k k1 h) kv = Repr k h (AssocValue k k1 kv) 

class Associate k v xs | k xs -> v where Source

Associate k v xs is essentially identical to (k :> v) ∈ xs , but the type v is inferred from k and xs.

Methods

association :: Membership xs (k :> v) Source

Instances

((~) (Elaborated k (Assoc Nat k1)) (Elaborate k (Assoc Nat k1) k2 (FindAssoc k1 k k1 k2 xs)) (Expecting k (Assoc Nat k1) ((:>) Nat k1 n v)), KnownPosition Nat n) => Associate k k k v xs 

type family FindAssoc key xs Source

Equations

FindAssoc k ((k :> v) : xs) = (Zero :> v) : MapSuccKey (FindAssoc k xs) 
FindAssoc k ((k' :> v) : xs) = MapSuccKey (FindAssoc k xs) 
FindAssoc k [] = [] 

Sugar

type family Elaborate key xs :: Elaborated k v Source

Equations

Elaborate k [] = Missing k 
Elaborate k `[x]` = Expecting x 
Elaborate k xs = Duplicate k 

data Elaborated k v Source

Constructors

Expecting v 
Missing k 
Duplicate k