summaryrefslogtreecommitdiff
path: root/src/Interpreter/Rep.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-09-22 23:11:37 +0200
committerTom Smeding <tom@tomsmeding.com>2024-09-22 23:11:37 +0200
commit7bc10684870e2249efbdcdddb4950f52d8527699 (patch)
tree8ff3ffd5966ead77edd9f66b61df9e92dc237a47 /src/Interpreter/Rep.hs
parent1d14fbd9665b25aef5672e0652d5e7e27bcd4908 (diff)
Interpreter typechecks, at the cost of compositionality of RepAc
Diffstat (limited to 'src/Interpreter/Rep.hs')
-rw-r--r--src/Interpreter/Rep.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Interpreter/Rep.hs b/src/Interpreter/Rep.hs
index aa2fcc9..c0c38b2 100644
--- a/src/Interpreter/Rep.hs
+++ b/src/Interpreter/Rep.hs
@@ -22,19 +22,19 @@ type family Rep t where
-- Mutable, and has a zero. The zero may not be O(1), but RepAcSparse (D2 t) will have an O(1) zero.
type family RepAcSparse t where
RepAcSparse TNil = ()
- RepAcSparse (TPair a b) = IORef (RepAcDense (TPair a b))
+ RepAcSparse (TPair a b) = IORef (RepAcSparse a, RepAcSparse b)
RepAcSparse (TEither a b) = TypeError (Text "Non-sparse coproduct is not a monoid")
RepAcSparse (TMaybe t) = IORef (Maybe (RepAcDense t)) -- allow the value to be dense, because the Maybe's zero can be used for the contents
- RepAcSparse (TArr n t) = IORef (RepAcDense (TArr n t)) -- empty array is zero
+ RepAcSparse (TArr n t) = IORef (Array n (RepAcSparse t)) -- empty array is zero
RepAcSparse (TScal sty) = IORef (ScalRep sty)
RepAcSparse (TAccum t) = TypeError (Text "RepAcSparse: Nested accumulators")
-- Immutable, and does not necessarily have a zero.
type family RepAcDense t where
RepAcDense TNil = ()
- RepAcDense (TPair a b) = (RepAcSparse a, RepAcSparse b)
+ -- RepAcDense (TPair a b) = (RepAcSparse a, RepAcSparse b)
RepAcDense (TEither a b) = Either (RepAcSparse a) (RepAcSparse b)
- RepAcDense (TMaybe t) = Maybe (RepAcSparse t)
- RepAcDense (TArr n t) = Array n (RepAcSparse t)
- RepAcDense (TScal sty) = ScalRep sty
- RepAcDense (TAccum t) = TypeError (Text "RepAcDense: Nested accumulators")
+ -- RepAcDense (TMaybe t) = RepAcSparse (TMaybe t) -- ^ This can be optimised to TMaybe (RepAcSparse t), but that makes accumAddDense very hard to write. And in any case, we don't need it because D2 will not produce Maybe of Maybe.
+ -- RepAcDense (TArr n t) = Array n (RepAcSparse t)
+ -- RepAcDense (TScal sty) = ScalRep sty
+ -- RepAcDense (TAccum t) = TypeError (Text "RepAcDense: Nested accumulators")