has-0.3: Entity based recordsSource codeContentsIndex
Data.Has
Portabilityunknown
Stabilityexperimental
Maintainernonowarn@gmail.com
Contents
Has class
Rows in records
Update and Lookup values from records
Labelled values
Defining labels
Make parsing error messages easier
Description
Entiry based records.
Synopsis
class Knows lab (TypeOf lab) s => Has lab s
type Row a = a ::: TyNil
(&) :: Append a b => a -> b -> a :&: b
type family a :&: b
row :: a -> Row a
(^=) :: Knows lab (TypeOf lab) s => lab -> TypeOf lab -> s -> s
(^.) :: Knows lab (TypeOf lab) s => lab -> s -> TypeOf lab
(^:) :: Knows lab (TypeOf lab) s => lab -> (TypeOf lab -> TypeOf lab) -> s -> s
class Contains (Labelled lab e) s => Knows lab e s | lab s -> e where
injl :: lab -> e -> s -> s
prjl :: lab -> s -> e
updl :: Knows lab b a => lab -> (b -> b) -> a -> a
data Labelled lab a
type :> lab a = Row (Labelled lab a)
(.>) :: lab -> a -> lab :> a
type family TypeOf a
type family RowOf a
rowOf :: TypeOf a -> RowOf a
data a ::: b
data TyNil
class Contains e s
Has class
class Knows lab (TypeOf lab) s => Has lab s Source

Same as Knows lab (TypeOf lab) s, Useful on writing type signitures.

Holds e == (lab .^ (lab ^= e $ s)) where lab :: lab; e :: TypeOf lab; s :: s

show/hide Instances
Knows lab (TypeOf lab) s => Has lab s
Rows in records
type Row a = a ::: TyNilSource
Row a is a type list which contains only one element of a. And every row in the records should be this type.
(&) :: Append a b => a -> b -> a :&: bSource

Concatenates between Rows or records. Records are concatenated rows. For example, Following expressions are valid.

 -- Concatenation of rows (i.e. record)
 row "string" & row True
 -- Concatenation of records
 (row 'c' & row ()) & (row False & row "string")
 -- ... And concatenations between a row and a record
 row () & (row False & row "string")
 (row 'c' & row ()) & row False
type family a :&: b Source
Represents concatenated rows or records.
row :: a -> Row aSource
Creates a Row of a.
Update and Lookup values from records
(^=) :: Knows lab (TypeOf lab) s => lab -> TypeOf lab -> s -> sSource
Strict version of injl
(^.) :: Knows lab (TypeOf lab) s => lab -> s -> TypeOf labSource
Strict version of prjl
(^:) :: Knows lab (TypeOf lab) s => lab -> (TypeOf lab -> TypeOf lab) -> s -> sSource
Strict version of updl
class Contains (Labelled lab e) s => Knows lab e s | lab s -> e whereSource
Injects and Projects a labelled values into records.
Methods
injl :: lab -> e -> s -> sSource
Injects a labelled value
prjl :: lab -> s -> eSource
Projects a labelled value
show/hide Instances
Contains (Labelled lab e) s => Knows lab e s
updl :: Knows lab b a => lab -> (b -> b) -> a -> aSource
Updates a labelled value
Labelled values
data Labelled lab a Source
Represents labelled value.
show/hide Instances
Bounded a => Bounded (Labelled lab a)
Eq a => Eq (Labelled lab a)
Ord a => Ord (Labelled lab a)
Read a => Read (Labelled lab a)
Show a => Show (Labelled lab a)
Arbitrary a => Arbitrary (Labelled lab a)
CoArbitrary a => CoArbitrary (Labelled lab a)
Monoid a => Monoid (Labelled lab a)
type :> lab a = Row (Labelled lab a)Source
Represents labelled row.
(.>) :: lab -> a -> lab :> aSource
Makes a labelled row.
Defining labels
type family TypeOf a Source
TypeOf a should indicate a type labelled by a
type family RowOf a Source
 RowOf a == a :> TypeOf a
rowOf :: TypeOf a -> RowOf aSource
Creates a row labelled by a
Make parsing error messages easier
data a ::: b Source
Cons a type onto type-list.
show/hide Instances
Contains e r => Contains e (::: h r)
Contains e (::: e r)
(Bounded a, Bounded b) => Bounded (::: a b)
(Eq a, Eq b) => Eq (::: a b)
(Ord a, Ord b) => Ord (::: a b)
(Read a, Read b) => Read (::: a b)
(Show a, Show b) => Show (::: a b)
(Arbitrary a, Arbitrary b) => Arbitrary (::: a b)
(CoArbitrary a, CoArbitrary b) => CoArbitrary (::: a b)
(Monoid a, Monoid b) => Monoid (::: a b)
Append y b => Append (::: x y) b
data TyNil Source
The empty type-list.
show/hide Instances
class Contains e s Source

Provides injection and projection into type lists.

Holds e == prj (inj e s) for all s and e.

show/hide Instances
Contains e r => Contains e (::: h r)
Contains e (::: e r)
Produced by Haddock version 2.6.1