on master help sign in
Add comments
commitc1cf9b74e976a70e65f0ddcbbd01f23fda06dc5d authorSridhar Ratnakumar <srid@srid.ca> dateFri 28 Aug 2020, 16:14 (6 years ago) parent133a55f
2 files changed+12−3
src/JRec.hs+8−3 src/JRec/Internal.hs+4
src/JRec.hs+8−3
@@ -10,7 +10,6 @@ module JRec
1010 append,
1111 union,
1212 insert,
13− -- insertOrSet
1413 )
1514where
1615
@@ -44,7 +43,9 @@ unField _ (_ R.:= value) = value
4443
4544-- Appends records, without removing duplicates.
4645--
47−-- FIXME: see spec
46+-- O(n + m) type check complexity.
47+--
48+-- FIXME: overwrites all indices (see spec)
4849append ::
4950 forall lhs rhs res.
5051 ( KnownNat (R.RecSize lhs),
@@ -61,7 +62,9 @@ append = R.combine
6162
6263-- Merges records, removing duplicates
6364--
64−-- Left-biased. Does not sort.
65+-- Left-biased. Does not sort.
66+--
67+-- O(n * m) type check complexity.
6568union ::
6669 forall lhs rhs res.
6770 ( KnownNat (R.RecSize lhs),
@@ -77,6 +80,8 @@ union ::
7780union = R.union
7881
7982-- | Insert a field into a record that does not already contain it
83+--
84+-- O(n) type check complexity.
8085insert ::
8186 forall label value lts res.
8287 ( KnownNat (1 + R.RecSize lts),
src/JRec/Internal.hs+4
@@ -200,6 +200,8 @@ unsafeRCons (_ := val) (MkRec vec#) =
200200 ST $ \s# ->
201201 case unsafeThawSmallArray# vec# s# of
202202 (# s'#, arr# #) ->
203+ -- Write the value to be cons'ed at the *end* (hence size#) of the
204+ -- array, because `Rec` stores values in reverse order.
203205 case writeSmallArray# arr# size# (unsafeCoerce# val) s'# of
204206 s''# ->
205207 case unsafeFreezeSmallArray# arr# s''# of
@@ -707,6 +709,8 @@ class NoConstraint x
707709
708710instance NoConstraint x
709711
712+-- | Convert a record into a list of fields.
713+--
710714-- | Not present in original superrecord
711715getFields :: RecApply fields fields NoConstraint => Rec fields -> [Any]
712716getFields =