summaryrefslogtreecommitdiff
path: root/src/Example.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-09-19 21:55:38 +0200
committerTom Smeding <tom@tomsmeding.com>2023-09-19 21:55:38 +0200
commit183e8b4a07231aae904b8234ddeb1c646c031173 (patch)
treed514667bb46f5bf6553abed83042a5771e3c39f2 /src/Example.hs
parent7095bcf4910e2b1525234ca8e88f4effc25315bd (diff)
Stuff
Diffstat (limited to 'src/Example.hs')
-rw-r--r--src/Example.hs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Example.hs b/src/Example.hs
index 99574c5..c8f12ba 100644
--- a/src/Example.hs
+++ b/src/Example.hs
@@ -4,6 +4,7 @@ module Example where
import AST
import AST.Pretty
import CHAD
+import Simplify
bin :: SOp (TPair a b) c -> Ex env a -> Ex env b -> Ex env c
@@ -18,12 +19,12 @@ senv1 = STScal STF32 `SCons` STScal STF32 `SCons` SNil
-- x4 = ((*) x3, x1)
-- in ( (+) x4
-- , let x5 = 1.0
--- x6 = inr (x5, x5)
+-- x6 = Inr (x5, x5)
-- in case x6 of
-- Inl x7 -> return ()
-- Inr x8 ->
-- let x9 = fst x8
--- x10 = inr (snd x3 * x9, fst x3 * x9)
+-- x10 = Inr (snd x3 * x9, fst x3 * x9)
-- in case x10 of
-- Inl x11 -> return ()
-- Inr x12 ->
@@ -47,6 +48,13 @@ ex1 =
(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 = _
+-- x y |- let z = x + y in z * (z + x)
+ex2 :: Ex [TScal TF32, TScal TF32] (TScal TF32)
+ex2 =
+ ELet ext (bin (OAdd STF32) (EVar ext (STScal STF32) (IS IZ))
+ (EVar ext (STScal STF32) IZ)) $
+ bin (OMul STF32)
+ (EVar ext (STScal STF32) IZ)
+ (bin (OAdd STF32)
+ (EVar ext (STScal STF32) IZ)
+ (EVar ext (STScal STF32) (IS (IS IZ))))