diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-10-21 23:20:57 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-10-21 23:20:57 +0200 |
commit | e7d7ac0fd8b81c1d6fae9ab7c1e4654133c631ea (patch) | |
tree | 4dc880e6956b42f0920382d772b49adc2a4ce556 /src/Interpreter/Rep.hs | |
parent | 246439502b78c4a8fcc27ab3296c67471a2b239d (diff) |
Tests
Diffstat (limited to 'src/Interpreter/Rep.hs')
-rw-r--r-- | src/Interpreter/Rep.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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) |