aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-10-23 23:44:49 +0200
committerTom Smeding <tom@tomsmeding.com>2025-10-23 23:44:49 +0200
commit3bb0ddec78194ebc1c133f8dcaf1ff83b873d320 (patch)
tree549de64835d6ff9829d5d4b0b903b20bc41c79a6
parent1adad63b14aa8d13295fb0d68fbdc8ab988775b2 (diff)
pipeline helpers in Example
-rw-r--r--src/Example.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Example.hs b/src/Example.hs
index bccc8de..2c51291 100644
--- a/src/Example.hs
+++ b/src/Example.hs
@@ -11,6 +11,7 @@ module Example where
import Array
import AST
+import AST.Count
import AST.Pretty
import AST.UnMonoid
import CHAD
@@ -28,6 +29,22 @@ import Example.Types
-- ppExpr senv5 $ simplifyN 20 $ let d = descr5 SMerge SMerge in freezeRet d (drev d ex5) (EConst ext STF32 1.0)
+pipeline :: KnownEnv env => CHADConfig -> Ex env t -> Ex (D2 t : env) (TPair t (Tup (D2E env)))
+pipeline config term
+ | Dict <- styKnown (d2 (typeOf term)) =
+ simplifyFix $ pruneExpr knownEnv $
+ simplifyFix $ unMonoid $
+ chad' config knownEnv $
+ simplifyFix $
+ term
+
+-- :seti -XOverloadedLabels -XPartialTypeSignatures -Wno-partial-type-signatures
+pipeline' :: KnownEnv env => CHADConfig -> Ex env t -> IO ()
+pipeline' config term
+ | Dict <- styKnown (d2 (typeOf term)) =
+ pprintExpr (pipeline config term)
+
+
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)