has-0.4: 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 Field a = a ::: TyNil
(&) :: Append a b => a -> b -> a :&: b
type family a :&: b
field :: a -> Field 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 = Field (Labelled lab a)
(.>) :: lab -> a -> lab :> a
type family TypeOf a
type family FieldOf a
fieldOf :: TypeOf a -> FieldOf 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 Field a = a ::: TyNilSource
Field a is a type list which contains only one element of a. And every field in the records should be this type.
(&) :: Append a b => a -> b -> a :&: bSource

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

 -- Concatenation of rows (i.e. record)
 field "string" & field True
 -- Concatenation of records
 (field 'c' & field ()) & (field False & field "string")
 -- ... And concatenations between a field and a record
 field () & (field False & field "string")
 (field 'c' & field ()) & field False
type family a :&: b Source
Represents concatenated rows or records.
field :: a -> Field aSource
Creates a Field 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 = Field (Labelled lab a)Source
Represents labelled field.
(.>) :: lab -> a -> lab :> aSource
Makes a labelled field.
Defining labels
type family TypeOf a Source
TypeOf a should indicate a type labelled by a
type family FieldOf a Source
 FieldOf a == a :> TypeOf a
fieldOf :: TypeOf a -> FieldOf aSource
Creates a field 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