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.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Interpreter/Rep.hs b/src/Interpreter/Rep.hs
index be2a4cc..9056901 100644
--- a/src/Interpreter/Rep.hs
+++ b/src/Interpreter/Rep.hs
@@ -22,6 +22,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 (TLEither a b) = Maybe (Either (Rep a) (Rep b))
-- Mutable, represents D2 of t. Has an O(1) zero.
type family RepAc t where
@@ -32,6 +33,7 @@ type family RepAc t where
RepAc (TArr n t) = IORef (Maybe (Array n (RepAc t)))
RepAc (TScal sty) = RepAcScal sty
RepAc (TAccum t) = TypeError (Text "RepAcSparse: Nested accumulators")
+ RepAc (TLEither a b) = IORef (Maybe (Either (RepAc a) (RepAc b)))
type family RepAcScal t where
RepAcScal TI32 = ()
@@ -57,8 +59,8 @@ vUnpair (Value (x, y)) = (Value x, Value y)
showValue :: Int -> STy t -> Rep t -> ShowS
showValue _ STNil () = showString "()"
showValue _ (STPair a b) (x, y) = showString "(" . showValue 0 a x . showString "," . showValue 0 b y . showString ")"
-showValue d (STEither a _) (Left x) = showParen (d > 10) $ showString "Left " . showValue 11 a x
-showValue d (STEither _ b) (Right y) = showParen (d > 10) $ showString "Right " . showValue 11 b y
+showValue d (STEither a _) (Left x) = showParen (d > 10) $ showString "Inl " . showValue 11 a x
+showValue d (STEither _ b) (Right y) = showParen (d > 10) $ showString "Inr " . showValue 11 b y
showValue _ (STMaybe _) Nothing = showString "Nothing"
showValue d (STMaybe t) (Just x) = showParen (d > 10) $ showString "Just " . showValue 11 t x
showValue d (STArr _ t) arr = showParen (d > 10) $
@@ -72,7 +74,10 @@ showValue _ (STScal sty) x = case sty of
STI32 -> shows x
STI64 -> shows x
STBool -> shows x
-showValue _ (STAccum t) _ = showString $ "<accumulator for " ++ ppSTy 0 t ++ ">"
+showValue _ (STAccum t) _ = showString $ "<accumulator for " ++ ppSMTy 0 t ++ ">"
+showValue _ (STLEither _ _) Nothing = showString "LNil"
+showValue d (STLEither a _) (Just (Left x)) = showParen (d > 10) $ showString "LInl " . showValue 11 a x
+showValue d (STLEither _ b) (Just (Right y)) = showParen (d > 10) $ showString "LInr " . showValue 11 b y
showEnv :: SList STy env -> SList Value env -> String
showEnv = \env vals -> "[" ++ intercalate ", " (showEntries env vals) ++ "]"