Skip to content

Commit

Permalink
[ experim ] Lightweight way of computing dependees
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Sep 26, 2024
1 parent c78b9a3 commit f6e3603
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Deriving/DepTyCheck/Gen/Core/ConsDerive.idr
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace NonObligatoryExts
argsTypeApps <- getTypeApps con

-- Get arguments which any other argument depends on
let dependees = concat $ downmap (mapIn weakenToSuper) $ argDeps con.args
let dependees = dependees con.args

-- Decide how constructor arguments would be named during generation
let bindNames = withIndex (fromList con.args) <&> map (bindNameRenamer . argName)
Expand Down
7 changes: 7 additions & 0 deletions src/Deriving/DepTyCheck/Util/Reflection.idr
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ argDeps args = do
flip upmapI args $ \i, deps => flip concatMap deps $ \candidates =>
maybe empty singleton $ last' $ mapMaybe tryToFit $ SortedSet.toList candidates

export
dependees : (args : List Arg) -> SortedSet $ Fin $ args.length
dependees args = do
let nameToIndex = SortedMap.fromList $ mapI args $ \i, arg => (argName arg, i)
let varsInTypes = concatMap (\arg => allVarNames' arg.type) args
fromList $ mapMaybe (lookup' nameToIndex) $ SortedSet.toList varsInTypes

export
record NamesInfoInTypes where
constructor Names
Expand Down

0 comments on commit f6e3603

Please sign in to comment.