summaryrefslogtreecommitdiff
path: root/src/Interpreter.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-11-09 11:34:04 +0100
committerTom Smeding <tom@tomsmeding.com>2024-11-09 11:34:04 +0100
commit2b1562d33bb9496aa449ef9d52735af0ec61c15c (patch)
tree77aa4f3195b1493828e3c82c9bae4b419ba27c64 /src/Interpreter.hs
parent992249ebf159ba3783a9345430013e52294c26aa (diff)
Some more primitive operators
Diffstat (limited to 'src/Interpreter.hs')
-rw-r--r--src/Interpreter.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Interpreter.hs b/src/Interpreter.hs
index 3c1aad0..576b0d9 100644
--- a/src/Interpreter.hs
+++ b/src/Interpreter.hs
@@ -170,6 +170,9 @@ interpretOp op arg = case op of
OIf -> if arg then Left () else Right ()
ORound64 -> round arg
OToFl64 -> fromIntegral arg
+ ORecip st -> floatingIsFractional st $ recip arg
+ OExp st -> floatingIsFractional st $ exp arg
+ OLog st -> floatingIsFractional st $ log arg
where
styIsEq :: SScalTy t -> (Eq (Rep (TScal t)) => r) -> r
styIsEq STI32 = id
@@ -523,6 +526,10 @@ numericIsNum STI64 = id
numericIsNum STF32 = id
numericIsNum STF64 = id
+floatingIsFractional :: ScalIsFloating st ~ True => SScalTy st -> ((Floating (ScalRep st), Ord (ScalRep st), ScalIsNumeric st ~ True) => r) -> r
+floatingIsFractional STF32 = id
+floatingIsFractional STF64 = id
+
unTupRepIdx :: f Z -> (forall m. f m -> Int -> f (S m))
-> SNat n -> Rep (Tup (Replicate n TIx)) -> f n
unTupRepIdx nil _ SZ _ = nil