From e7d7ac0fd8b81c1d6fae9ab7c1e4654133c631ea Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 21 Oct 2024 23:20:57 +0200 Subject: Tests --- src/Interpreter/Rep.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Interpreter') diff --git a/src/Interpreter/Rep.hs b/src/Interpreter/Rep.hs index adb4eba..ed307c0 100644 --- a/src/Interpreter/Rep.hs +++ b/src/Interpreter/Rep.hs @@ -39,5 +39,16 @@ type family RepAcDense t where -- RepAcDense (TScal sty) = ScalRep sty -- RepAcDense (TAccum t) = TypeError (Text "RepAcDense: Nested accumulators") -newtype Value t = Value (Rep t) +newtype Value t = Value { unValue :: Rep t } +liftV :: (Rep a -> Rep b) -> Value a -> Value b +liftV f (Value x) = Value (f x) + +liftV2 :: (Rep a -> Rep b -> Rep c) -> Value a -> Value b -> Value c +liftV2 f (Value x) (Value y) = Value (f x y) + +vPair :: Value a -> Value b -> Value (TPair a b) +vPair = liftV2 (,) + +vUnpair :: Value (TPair a b) -> (Value a, Value b) +vUnpair (Value (x, y)) = (Value x, Value y) -- cgit v1.2.3-70-g09d2