From 919a36f8eed21501357185a90e2b7a4d9eaf7f08 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 28 Apr 2025 12:05:06 +0200 Subject: WIP interpreter support for new monoidal accumulators --- src/Interpreter/Rep.hs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/Interpreter/Rep.hs') 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 } -- cgit v1.2.3-70-g09d2