summaryrefslogtreecommitdiff
path: root/src/Example.hs
diff options
context:
space:
mode:
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 = _