summaryrefslogtreecommitdiff
path: root/src/Interpreter/Rep.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Interpreter/Rep.hs')
-rw-r--r--src/Interpreter/Rep.hs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/Interpreter/Rep.hs b/src/Interpreter/Rep.hs
index 9056901..1226b0c 100644
--- a/src/Interpreter/Rep.hs
+++ b/src/Interpreter/Rep.hs
@@ -6,7 +6,6 @@ module Interpreter.Rep where
import Data.List (intersperse, intercalate)
import Data.Foldable (toList)
import Data.IORef
-import GHC.TypeError
import Array
import AST
@@ -24,23 +23,14 @@ type family Rep t where
Rep (TAccum t) = RepAc t
Rep (TLEither a b) = Maybe (Either (Rep a) (Rep b))
--- Mutable, represents D2 of t. Has an O(1) zero.
+-- Mutable, represents monoid types t.
type family RepAc t where
RepAc TNil = ()
- RepAc (TPair a b) = IORef (Maybe (RepAc a, RepAc b))
- RepAc (TEither a b) = IORef (Maybe (Either (RepAc a) (RepAc b)))
- RepAc (TMaybe t) = IORef (Maybe (RepAc t))
- RepAc (TArr n t) = IORef (Maybe (Array n (RepAc t)))
- RepAc (TScal sty) = RepAcScal sty
- RepAc (TAccum t) = TypeError (Text "RepAcSparse: Nested accumulators")
+ RepAc (TPair a b) = (RepAc a, RepAc b)
RepAc (TLEither a b) = IORef (Maybe (Either (RepAc a) (RepAc b)))
-
-type family RepAcScal t where
- RepAcScal TI32 = ()
- RepAcScal TI64 = ()
- RepAcScal TF32 = IORef Float
- RepAcScal TF64 = IORef Double
- RepAcScal TBool = ()
+ RepAc (TMaybe t) = IORef (Maybe (RepAc t))
+ RepAc (TArr n t) = Array n (RepAc t)
+ RepAc (TScal sty) = IORef (ScalRep sty)
newtype Value t = Value { unValue :: Rep t }