module Datafix.Worklist.Graph where
import Control.Monad.Trans.Reader
import Datafix.IntArgsMonoSet (IntArgsMonoSet)
import qualified Datafix.IntArgsMonoSet as IntArgsMonoSet
import Datafix.MonoMap (MonoMapKey)
import Datafix.Utils.TypeLevel
data PointInfo domain
= PointInfo
{ value :: !(Maybe (ReturnType domain))
, references :: !(IntArgsMonoSet (Products (ParamTypes domain)))
, referrers :: !(IntArgsMonoSet (Products (ParamTypes domain)))
, iterations :: !Int
}
deriving instance (Eq (ReturnType domain), Eq (IntArgsMonoSet (Products (ParamTypes domain)))) => Eq (PointInfo domain)
deriving instance (Show (ReturnType domain), Show (IntArgsMonoSet (Products (ParamTypes domain)))) => Show (PointInfo domain)
emptyPointInfo :: PointInfo domain
emptyPointInfo = PointInfo Nothing IntArgsMonoSet.empty IntArgsMonoSet.empty 0
data Diff a
= Diff
{ added :: !(IntArgsMonoSet a)
, removed :: !(IntArgsMonoSet a)
}
computeDiff :: MonoMapKey k => IntArgsMonoSet k -> IntArgsMonoSet k -> Diff k
computeDiff a b =
Diff (IntArgsMonoSet.difference b a) (IntArgsMonoSet.difference a b)
class GraphRef (ref :: * -> *) where
updatePoint :: MonoMapKey (Products (ParamTypes domain)) => Int -> Products (ParamTypes domain) -> ReturnType domain -> IntArgsMonoSet (Products (ParamTypes domain)) -> ReaderT (ref domain) IO (PointInfo domain)
lookup :: MonoMapKey (Products (ParamTypes domain)) => Int -> Products (ParamTypes domain) -> ReaderT (ref domain) IO (Maybe (PointInfo domain))
lookupLT :: MonoMapKey (Products (ParamTypes domain)) => Int -> Products (ParamTypes domain) -> ReaderT (ref domain) IO [(Products (ParamTypes domain), PointInfo domain)]