diff options
Diffstat (limited to 'src/CHAD/Interpreter')
| -rw-r--r-- | src/CHAD/Interpreter/Rep.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/CHAD/Interpreter/Rep.hs b/src/CHAD/Interpreter/Rep.hs index fadc6be..32a1a48 100644 --- a/src/CHAD/Interpreter/Rep.hs +++ b/src/CHAD/Interpreter/Rep.hs @@ -27,6 +27,7 @@ type family Rep t where Rep (TArr n t) = Array n (Rep t) Rep (TScal sty) = ScalRep sty Rep (TAccum t) = RepAc t + Rep (TUser t) = Rep (UserRep t) -- Mutable, represents monoid types t. type family RepAc t where @@ -36,6 +37,7 @@ type family RepAc t where RepAc (TMaybe t) = IORef (Maybe (RepAc t)) RepAc (TArr n t) = Array n (RepAc t) RepAc (TScal sty) = IORef (ScalRep sty) + RepAc (TUser t) = IORef (Rep (UserRep t)) newtype Value t = Value { unValue :: Rep t } @@ -73,6 +75,8 @@ showValue d (STScal sty) x = case sty of STI64 -> showsPrec d x STBool -> showsPrec d x showValue _ (STAccum t) _ = showString $ "<accumulator for " ++ ppSMTy 0 t ++ ">" +showValue d (STUser t) x = + showParen (d > 10) $ showString ("User[" ++ show (typeOfProxy t) ++ "] ") . showValue 11 (userRepTy t) x showEnv :: SList STy env -> SList Value env -> String showEnv = \env vals -> "[" ++ intercalate ", " (showEntries env vals) ++ "]" @@ -100,6 +104,7 @@ rnfRep (STScal t) x = case t of STF64 -> rnf x STBool -> rnf x rnfRep STAccum{} _ = error "Cannot rnf accumulators" +rnfRep (STUser t) x = rnfRep (userRepTy t) x instance KnownTy t => NFData (Value t) where rnf (Value x) = rnfRep (knownTy @t) x |
