has- Entity based records





Entiry based records.


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


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.


injl :: lab -> e -> s -> sSource

Injects a labelled value

prjl :: lab -> s -> eSource

Projects a labelled value


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.


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.


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.

class Contains e s Source

Provides injection and projection into type lists.

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


Contains e r => Contains e (::: h r) 
Contains e (::: e r)