summaryrefslogtreecommitdiff
path: root/src/Example.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-09-16 12:32:56 +0200
committerTom Smeding <tom@tomsmeding.com>2023-09-16 12:32:56 +0200
commit35cc10682f35dafba98000bf35191896a6432624 (patch)
tree7fbe9080ec502f3398a5329e15e5d263182d91a3 /src/Example.hs
parente52a3e7e89f6ad41d4291a467e4c1d3571614b0a (diff)
CHAD ops
Diffstat (limited to 'src/Example.hs')
-rw-r--r--src/Example.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Example.hs b/src/Example.hs
new file mode 100644
index 0000000..89b2082
--- /dev/null
+++ b/src/Example.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE DataKinds #-}
+module Example where
+
+import AST
+import CHAD
+
+
+bin :: SOp (TPair a b) c -> Ex env a -> Ex env b -> Ex env c
+bin op a b = EOp ext op (EPair ext a b)
+
+-- x y |- x * y + x
+ex1 :: Ex [TScal TF32, TScal TF32] (TScal TF32)
+ex1 =
+ bin (OAdd STF32)
+ (bin (OMul STF32)
+ (EVar ext (STScal STF32) (IS IZ))
+ (EVar ext (STScal STF32) IZ))
+ (EVar ext (STScal STF32) (IS IZ))
+
+-- -- x y |- let z = x + y in z * (z + x)
+-- ex2 :: Ex [TScal TF32, TScal TF32] (TScal TF32)
+-- ex2 = _