diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-04-28 12:05:06 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-04-28 12:05:06 +0200 |
commit | 919a36f8eed21501357185a90e2b7a4d9eaf7f08 (patch) | |
tree | 3c6c975ea9f51c8ad46105e4cbba08d9c7f77003 /src/Interpreter | |
parent | b1664532eaebdf0409ab6d93fc0ba2ef8dfbf372 (diff) |
WIP interpreter support for new monoidal accumulators
Diffstat (limited to 'src/Interpreter')
-rw-r--r-- | src/Interpreter/Rep.hs | 20 |
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 } |