diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-11-04 23:09:21 +0100 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-11-04 23:09:21 +0100 |
| commit | 57779d4303f377004705c8da06a5ac46177950b2 (patch) | |
| tree | 0407089403d3d5c2de778c1aab7aed8adf2d01c0 /src/Interpreter.hs | |
| parent | 351667a3ff14c96a8dfe3a2f1dd76b6e1a996542 (diff) | |
Diffstat (limited to 'src/Interpreter.hs')
| -rw-r--r-- | src/Interpreter.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Interpreter.hs b/src/Interpreter.hs index d982261..e1c81cd 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -121,11 +121,11 @@ interpret'Rec env = \case arrayMapM (\x -> interpret' (V t x `SCons` env) a) =<< interpret' env b EFold1Inner _ _ a b c -> do let t = typeOf b - let f = \x y -> interpret' (V t y `SCons` V t x `SCons` env) a + let f = \x -> interpret' (V (STPair t t) x `SCons` env) a x0 <- interpret' env b arr <- interpret' env c let sh `ShCons` n = arrayShape arr - arrayGenerateM sh $ \idx -> foldM f x0 [arrayIndex arr (idx `IxCons` i) | i <- [0 .. n - 1]] + arrayGenerateM sh $ \idx -> foldM (curry f) x0 [arrayIndex arr (idx `IxCons` i) | i <- [0 .. n - 1]] ESum1Inner _ e -> do arr <- interpret' env e let STArr _ (STScal t) = typeOf e @@ -162,14 +162,14 @@ interpret'Rec env = \case return $ arrayGenerateLin sh (\i -> (arr1 `arrayIndexLinear` i, arr2 `arrayIndexLinear` i)) EFold1InnerD1 _ _ a b c -> do let t = typeOf b - let f = \x y -> interpret' (V t y `SCons` V t x `SCons` env) a + let f = \x -> interpret' (V (STPair t t) x `SCons` env) a x0 <- interpret' env b arr <- interpret' env c let sh `ShCons` n = arrayShape arr -- TODO: this is very inefficient, even for an interpreter; with mutable -- arrays this can be a lot better with no lists res <- arrayGenerateM sh $ \idx -> do - (y, stores) <- mapAccumLM f x0 [arrayIndex arr (idx `IxCons` i) | i <- [0 .. n - 1]] + (y, stores) <- mapAccumLM (curry f) x0 [arrayIndex arr (idx `IxCons` i) | i <- [0 .. n - 1]] return (y, arrayFromList (ShNil `ShCons` n) stores) return (arrayMap fst res ,arrayGenerate (sh `ShCons` n) $ \(idx `IxCons` i) -> |
