@@ -11,6 +11,7 @@ import Deriving.Show
1111import Language.Reflection
1212import Language.Reflection.Expr
1313import Language.Reflection.Syntax
14+ import Language.Reflection.Logging
1415
1516%language ElabReflection
1617
@@ -292,14 +293,14 @@ emptyLeaves : (dg : DependencyGraph) -> FinSet dg.freeVars
292293emptyLeaves dg = intersection dg. empties $ leaves dg
293294
294295||| List all the free variables without a value in order of dependency
295- flattenEmpties : (dg : DependencyGraph) -> SnocList $ Fin dg.freeVars
296+ flattenEmpties : Monad m => (dg : DependencyGraph) -> m $ SnocList $ Fin dg.freeVars
296297flattenEmpties dg = flattenEmpties' dg [< ]
297298 where
298- flattenEmpties' : (dg : DependencyGraph) -> SnocList (Fin dg.freeVars) -> SnocList $ Fin dg.freeVars
299+ flattenEmpties' : (dg : DependencyGraph) -> SnocList (Fin dg.freeVars) -> m $ SnocList $ Fin dg.freeVars
299300 flattenEmpties' dg@(MkDG {freeVars, fvData, fvDeps, empties, nameToId, holeToId}) ctx = do
300- let els = emptyLeaves dg
301+ els <- pure $ id $ emptyLeaves dg
301302 let False = null els
302- | _ => ctx
303+ | _ => pure ctx
303304 -- Now els is a non-empty subset of dg.empties
304305 flattenEmpties'
305306 -- `assert_smaller dg` is a workaround for a non-working `assert_smaller empties`
@@ -324,12 +325,12 @@ filterEmpty = foldl myfun []
324325
325326||| Calculate UnificationResult (var-to-value mappings and empty leaf dependency order)
326327export
327- finalizeDG : (task : UnificationTask) -> (dg : DependencyGraph) -> UnificationResult
328+ finalizeDG : Monad m => MonadLog m => (task : UnificationTask) -> (dg : DependencyGraph) -> m UnificationResult
328329finalizeDG task dg = do
329- let fvOrder = flattenEmpties dg
330- let urList = filterEmpty dg. fvData
331- let (lhsRL, rhsRL) = List . splitAt task. lfv urList
332- MkUR
330+ fvOrder <- flattenEmpties dg
331+ urList <- pure $ id $ filterEmpty dg. fvData
332+ (lhsRL, rhsRL) <- pure $ id $ List . splitAt task. lfv urList
333+ pure $ MkUR
333334 { task
334335 , uniDg = dg
335336 , lhsResult = fromList lhsRL
0 commit comments