diff options
Diffstat (limited to 'src/Example.hs')
-rw-r--r-- | src/Example.hs | 18 |
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)))) |