Skip to content

Commit

Permalink
🧩 [consolidate]: Minor tidy up.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyp committed Sep 21, 2023
1 parent 6d1458d commit 6db70f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions src/EvalGraph.purs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,14 @@ evalWithConfig { g, n, γα } e =
pure (eα × vα)

graphGC :: forall g. Graph g => GraphConfig g -> Raw Expr -> String + GaloisConnection (Set Vertex) (Set Vertex)
graphGC { g: g0, n, γα } e =
let
Identity q = (runWithGraphAllocT (g0 × n) :: _ -> Identity _) $ do
eα <- alloc e
vα <- eval γα eα S.empty
pure (vα × eα)
in
do
(g × _) × vα × eα <- q
pure $
{ fwd: \αs -> G.vertices (fwdSlice αs g) `intersection` vertices vα
, bwd: \αs -> G.vertices (bwdSlice αs g) `intersection` vertices eα -- needs to include γα
}
graphGC { g: g0, n, γα } e = do
(g × _) × vα × eα <- q
pure $
{ fwd: \αs -> G.vertices (fwdSlice αs g) `intersection` vertices vα
, bwd: \αs -> G.vertices (bwdSlice αs g) `intersection` vertices eα -- needs to include γα
}
where
Identity q = (runWithGraphAllocT (g0 × n) :: _ -> Identity _) $ do
eα <- alloc e
vα <- eval γα eα S.empty
pure (vα × eα)
2 changes: 1 addition & 1 deletion src/GaloisConnection.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type GaloisConnection a b =
}

deMorgan :: forall a b. BooleanLattice a => BooleanLattice b => Endo (a -> b)
deMorgan f = neg >>> f >>> neg
deMorgan = (neg >>> _) >>> (_ >>> neg)

-- Could unify deMorgan and dual but would need to reify notion of opposite category.
dual :: forall a b. BooleanLattice a => BooleanLattice b => GaloisConnection a b -> GaloisConnection b a
Expand Down
2 changes: 1 addition & 1 deletion test/Util.purs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ testGraph s gconf { δv, bwd_expect, fwd_expect } = do
-- | Eval
e <- desug s
tEval1 <- preciseTime
(g × _) × (eα × vα) <- evalWithConfig gconf e >>= except
(g × _) × eα × vα <- evalWithConfig gconf e >>= except
tEval2 <- preciseTime

-- | Backward
Expand Down

0 comments on commit 6db70f6

Please sign in to comment.