From b1664532eaebdf0409ab6d93fc0ba2ef8dfbf372 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 27 Apr 2025 23:34:59 +0200 Subject: WIP revamp accumulators again: explicit monoid types No more D2 in accumulators! Paving the way for configurable sparsity of products and arrays. The idea is to make separate monoid types for a "product cotangent" and an "array cotangent" that can be lowered to either a sparse monoid or a non-sparse monoid. Downsides of this approach: lots of API duplication. --- src/Language/AST.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Language') diff --git a/src/Language/AST.hs b/src/Language/AST.hs index 84544f8..8bcb5e5 100644 --- a/src/Language/AST.hs +++ b/src/Language/AST.hs @@ -72,8 +72,8 @@ data NExpr env t where -> NExpr env t -- accumulation effect on monoids - NEWith :: STy t -> NExpr env (D2 t) -> Var name (TAccum t) -> NExpr ('(name, TAccum t) : env) a -> NExpr env (TPair a (D2 t)) - NEAccum :: STy t -> SAcPrj p t a -> NExpr env (AcIdx p t) -> NExpr env (D2 a) -> NExpr env (TAccum t) -> NExpr env TNil + NEWith :: SMTy t -> NExpr env t -> Var name (TAccum t) -> NExpr ('(name, TAccum t) : env) a -> NExpr env (TPair a t) + NEAccum :: SMTy t -> SAcPrj p t a -> NExpr env (AcIdx p t) -> NExpr env a -> NExpr env (TAccum t) -> NExpr env TNil -- partiality NEError :: STy a -> String -> NExpr env a -- cgit v1.2.3-70-g09d2