From 930fa35ee83ac2a6968ce12c44b7397b8b35457c Mon Sep 17 00:00:00 2001 From: Roly Perera Date: Tue, 3 Oct 2023 13:49:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9=20[add-unused]:=20Start=20on=20eva?= =?UTF-8?q?l=5Fprog.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EvalGraph.purs | 4 ++-- src/Module.purs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/EvalGraph.purs b/src/EvalGraph.purs index 57f28fb7d..c577dcb75 100644 --- a/src/EvalGraph.purs +++ b/src/EvalGraph.purs @@ -194,8 +194,8 @@ graphGC { g, n, progCxt: ProgCxt { γ } } e = do vα <- eval γ eα S.empty pure (eα × vα) let --- dom = vertices progCxt `union` vertices eα + -- dom = vertices progCxt `union` vertices eα fwd αs = vertices (fwdSlice αs g') `intersection` vertices vα bwd αs = vertices (bwdSlice αs g') `intersection` sinks g' --- trace (show (S.size $ sinks g' `S.difference` dom) <> " sinks not in inputs.") \_ -> + -- trace (show (S.size $ sinks g' `S.difference` dom) <> " sinks not in inputs.") \_ -> pure { gc: GC { fwd, bwd }, γα: γ, eα, g: g', vα } diff --git a/src/Module.purs b/src/Module.purs index 0bfb046e0..cc404aefa 100644 --- a/src/Module.purs +++ b/src/Module.purs @@ -9,7 +9,7 @@ import Control.Monad.Error.Class (liftEither, throwError) import Control.Monad.Except (class MonadError) import Data.Either (Either(..)) import Data.HTTP.Method (Method(..)) -import Data.List (List(..), (:)) +import Data.List (List(..), foldl, (:)) import Data.Newtype (class Newtype) import Data.Set (empty) import Data.Traversable (traverse) @@ -62,7 +62,7 @@ loadModule file (ProgCxt r@{ mods, γ }) = do src <- loadFile (Folder "fluid/lib") file mod <- parse src module_ >>= desugarModuleFwd >>= traverse (const fresh) γ' <- eval_module γ mod empty - pure $ ProgCxt r{ mods = mod : mods, γ = γ <+> γ' } + pure $ ProgCxt r { mods = mod : mods, γ = γ <+> γ' } defaultImports :: forall m. MonadAff m => MonadGraphAlloc m => m (ProgCxt Vertex) defaultImports = do @@ -84,5 +84,10 @@ openDatasetAs file x { g, n, progCxt: ProgCxt r@{ γ, datasets } } = do runWithGraphAllocT (g × n) do eα <- desug s >>= alloc v <- eval γ eα empty - pure $ D.singleton x v × ProgCxt (r{ datasets = eα : datasets }) + pure $ D.singleton x v × ProgCxt (r { datasets = eα : datasets }) pure ({ g: g', n: n', progCxt } × xv) + +eval_progCxt :: forall m. MonadGraphAlloc m => ProgCxt Vertex -> m (Env Vertex) +eval_progCxt (ProgCxt { mods }) = + traverse alloc primitives + >>= foldl (>=>) pure (mods <#> \mod γ' -> eval_module γ' mod empty)