summaryrefslogtreecommitdiff
path: root/src/Interpreter.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-11-08 20:29:29 +0100
committerTom Smeding <tom@tomsmeding.com>2024-11-08 20:29:29 +0100
commit4fcdb7118e0084f192753ea6c70394352a27d5ed (patch)
treec5e91ae438b6f4c3e5075bf591e5fbe28aa5d96b /src/Interpreter.hs
parent83692cf41f76272423445c9cbbad65561ee3b50c (diff)
Custom derivatives
Diffstat (limited to 'src/Interpreter.hs')
-rw-r--r--src/Interpreter.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Interpreter.hs b/src/Interpreter.hs
index abc9800..47514ae 100644
--- a/src/Interpreter.hs
+++ b/src/Interpreter.hs
@@ -118,6 +118,10 @@ interpret'Rec env = \case
-> arrayIndex <$> interpret' env a <*> (unTupRepIdx IxNil IxCons n <$> interpret' env b)
EShape _ e | STArr n _ <- typeOf e -> tupRepIdx shUncons n . arrayShape <$> interpret' env e
EOp _ op e -> interpretOp op <$> interpret' env e
+ ECustom _ _ _ _ pr _ _ e1 e2 -> do
+ e1' <- interpret' env e1
+ e2' <- interpret' env e2
+ interpret' (Value e2' `SCons` Value e1' `SCons` SNil) pr
EWith e1 e2 -> do
initval <- interpret' env e1
withAccum (typeOf e1) (typeOf e2) initval $ \accum ->