Skip to content

Commit

Permalink
🧩 [add-unused]: Start on eval_prog.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyp committed Oct 3, 2023
1 parent 34ec3e3 commit 930fa35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/EvalGraph.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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α }
11 changes: 8 additions & 3 deletions src/Module.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)

0 comments on commit 930fa35

Please sign in to comment.