summaryrefslogtreecommitdiff
path: root/src/CHAD.hs
diff options
context:
space:
mode:
authorTom Smeding <t.j.smeding@uu.nl>2024-12-06 16:59:59 +0100
committerTom Smeding <t.j.smeding@uu.nl>2024-12-06 16:59:59 +0100
commit0ccd55fc7b3d5511935111d0e2712f452da035f4 (patch)
tree91f4625dd2bcc5db14ff319084efabff36aa1e15 /src/CHAD.hs
parent728909852208587c3c4c63da302d22e67d5cc915 (diff)
WIP UnMonoid (to be used for compiling to C)
Diffstat (limited to 'src/CHAD.hs')
-rw-r--r--src/CHAD.hs52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/CHAD.hs b/src/CHAD.hs
index 04e3ac4..aa5bd4c 100644
--- a/src/CHAD.hs
+++ b/src/CHAD.hs
@@ -320,61 +320,9 @@ indexTupD1Id (SS n) | Refl <- indexTupD1Id n = Refl
zero :: STy t -> Ex env (D2 t)
zero = EZero
--- TODO: this original definition needs to be used as the post-processing after
--- simplification, to eliminate the monoid operations from the AST
--- zero STNil = ENil ext
--- zero (STPair t1 t2) = EInl ext (STPair (d2 t1) (d2 t2)) (ENil ext)
--- zero (STEither t1 t2) = EInl ext (STEither (d2 t1) (d2 t2)) (ENil ext)
--- zero (STArr n t) = EBuild ext n (eTup (sreplicate n (EConst ext STI64 0))) (zero t)
--- zero (STScal t) = case t of
--- STI32 -> ENil ext
--- STI64 -> ENil ext
--- STF32 -> EConst ext STF32 0.0
--- STF64 -> EConst ext STF64 0.0
--- STBool -> ENil ext
--- zero STAccum{} = error "Accumulators not allowed in input program"
plus :: STy t -> Ex env (D2 t) -> Ex env (D2 t) -> Ex env (D2 t)
plus = EPlus
--- plus STNil _ _ = ENil ext
--- plus (STPair t1 t2) a b =
--- let t = STPair (d2 t1) (d2 t2)
--- in plusSparse t a b $
--- EPair ext (plus t1 (EFst ext (EVar ext t (IS IZ)))
--- (EFst ext (EVar ext t IZ)))
--- (plus t2 (ESnd ext (EVar ext t (IS IZ)))
--- (ESnd ext (EVar ext t IZ)))
--- plus (STEither t1 t2) a b =
--- let t = STEither (d2 t1) (d2 t2)
--- in plusSparse t a b $
--- ECase ext (EVar ext t (IS IZ))
--- (ECase ext (EVar ext t (IS IZ))
--- (EInl ext (d2 t2) (plus t1 (EVar ext (d2 t1) (IS IZ)) (EVar ext (d2 t1) IZ)))
--- (EError t "plus l+r"))
--- (ECase ext (EVar ext t (IS IZ))
--- (EError t "plus r+l")
--- (EInr ext (d2 t1) (plus t2 (EVar ext (d2 t2) (IS IZ)) (EVar ext (d2 t2) IZ))))
--- plus STArr{} _ _ = error "TODO plus on arrays"
--- plus (STScal t) a b = case t of
--- STI32 -> ENil ext
--- STI64 -> ENil ext
--- STF32 -> EOp ext (OAdd STF32) (EPair ext a b)
--- STF64 -> EOp ext (OAdd STF64) (EPair ext a b)
--- STBool -> ENil ext
--- plus STAccum{} _ _ = error "Accumulators not allowed in input program"
-
--- plusSparse :: STy a
--- -> Ex env (TEither TNil a) -> Ex env (TEither TNil a)
--- -> Ex (a : a : env) a
--- -> Ex env (TEither TNil a)
--- plusSparse t a b adder =
--- ELet ext b $
--- ECase ext (weakenExpr WSink a)
--- (EVar ext (STEither STNil t) (IS IZ))
--- (EInr ext STNil
--- (ECase ext (EVar ext (STEither STNil t) (IS IZ))
--- (EVar ext t (IS IZ))
--- (weakenExpr (WCopy (WCopy WSink)) adder)))
zeroTup :: SList STy env0 -> Ex env (Tup (D2E env0))
zeroTup SNil = ENil ext