File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ import Data.Equality.Graph.Lens
6060
6161import Data.Equality.Utils
6262
63+ import GHC.Stack (HasCallStack )
64+
6365-- ROMES:TODO: join things built in paralell?
6466-- instance Ord1 l => Semigroup (EGraph l) where
6567-- (<>) eg1 eg2 = undefined -- not so easy
@@ -310,7 +312,7 @@ canonicalize (Node enode) eg = Node $ fmap (`find` eg) enode
310312-- | Find the canonical representation of an e-class id in the e-graph
311313--
312314-- Invariant: The e-class id always exists.
313- find :: ClassId -> EGraph a l -> ClassId
315+ find :: HasCallStack => ClassId -> EGraph a l -> ClassId
314316find cid = findRepr cid . unionFind
315317{-# INLINE find #-}
316318
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ import Data.Equality.Graph.Nodes
2222import Data.Equality.Graph.Classes
2323import Data.Equality.Graph.ReprUnionFind
2424
25+ import GHC.Stack (HasCallStack )
26+
2527-- | A 'Lens'' as defined in other lenses libraries
2628type Lens' s a = forall f . Functor f = > (a -> f a ) -> (s -> f s )
2729type Traversal s t a b = forall f . Applicative f = > (a -> f b ) -> (s -> f t )
@@ -39,7 +41,7 @@ type Traversal s t a b = forall f. Applicative f => (a -> f b) -> (s -> f t)
3941-- | Lens for the e-class with the given id in an e-graph
4042--
4143-- Calls 'error' when the e-class doesn't exist
42- _class :: ClassId -> Lens' (EGraph a l ) (EClass a l )
44+ _class :: HasCallStack => ClassId -> Lens' (EGraph a l ) (EClass a l )
4345_class i afa s =
4446 let canon_id = findRepr i (unionFind s)
4547 in (\ c' -> s { classes = IM. insert canon_id c' (classes s) }) <$> afa (classes s IM. ! canon_id)
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import Data.Equality.Graph.Classes.Id
2121
2222import qualified Data.Equality.Utils.IntToIntMap as IIM
2323import GHC.Exts ((+#) , Int (.. ), Int #)
24+ import GHC.Stack (HasCallStack )
2425
2526type RUFSize = Int #
2627
@@ -97,7 +98,8 @@ unionSets a b (RUF im si) = (a, RUF (IIM.insert b a im) si)
9798 -- new_hc = IM.adjust ((b:) . (represented_by_b <>)) a (IM.delete b hc)
9899
99100-- | Find the canonical representation of an e-class id
100- findRepr :: ClassId -> ReprUnionFind
101+ findRepr :: HasCallStack
102+ => ClassId -> ReprUnionFind
101103 -> ClassId -- ^ The found canonical representation
102104#if __GLASGOW_HASKELL__ >= 902
103105findRepr v@ (I # v# ) (RUF m s) =
You can’t perform that action at this time.
0 commit comments