3 | module Data.Record.SmartConstructors
7 | %hide Builtin.infixr.(#)
16 | {a : String -> Type}
17 | (f : Field a -> Type)
18 | (flds : Fields a) where
19 | constructor MkCheckable
20 | mkCheckable : Record f flds
24 | (a : String -> Type)
25 | (f : Field a -> Type)
26 | (flds : Fields a) where
29 | {auto 0 pos : IsYes (name `isField` flds)}
30 | value : f (field (toWitness pos))
33 | Nil : Checkable f []
34 | Nil = MkCheckable $
MkRecord []
37 | (::) : {flds : Fields a} ->
38 | (entry : Entry a f flds) ->
39 | Checkable f (remove (toWitness entry.pos)) ->
41 | ((name ::= value) {pos}) :: rec
44 | $
insertLookedup (toWitness pos) value rec.mkCheckable.content
51 | {a : String -> Type}
52 | (f : Field a -> Type)
53 | (flds : Fields a) where
54 | constructor MkInferrable
55 | mkInferrable : Record f flds
58 | record Entry (a : String -> Type) (f : Field a -> Type) where
62 | value : f (
name ** type)
65 | Nil : Inferrable f []
66 | Nil = MkInferrable $
MkRecord []
69 | (::) : {flds : Fields a} ->
70 | (entry : Entry a f) ->
71 | (rec : Inferrable f flds) ->
72 | {auto 0 fresh : (
entry.name ** entry.type)
# flds} ->
73 | Inferrable f ((
entry.name ** entry.type)
:: flds)
74 | ((name ::= value) :: rec)
77 | $
(value :: rec.mkInferrable.content)
81 | BasicRecord : (f : Type -> Type) -> Fields (const Type) -> Type
82 | BasicRecord f flds = Record (\ x => f (snd x)) flds
87 | mkBasicRecord : BasicRecord f flds -> BasicRecord f flds
88 | mkBasicRecord rec = rec