Skip to content

Commit

Permalink
Merge pull request #714 from melt-umn/fix/rm-old-generated
Browse files Browse the repository at this point in the history
Fix #713, actually delete old generated files
  • Loading branch information
krame505 authored Oct 14, 2022
2 parents bf54c76 + ff08a15 commit 4280d0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ IO<()> ::= silverGen::String keepFiles::[String] r::Decorated RootSpec
exit(-5);
});
});
oldSrcFiles::[String] <- listContents(srcPath);
srcDirContents::[String] <- listContents(srcPath);
oldSrcFiles::[String] <- filterM(isFile, map(append(srcPath, _), srcDirContents));
deleteFiles(removeAll(keepFiles, oldSrcFiles));
deleteDirFiles(binPath);
writeFiles(srcPath, r.genFiles);
Expand Down
23 changes: 23 additions & 0 deletions grammars/silver/core/List.sv
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ function filter
else filter(f, tail(lst));
}

@{--
- Monadic (actually Applicative) version of filter
-
- @param f The filter function
- @param lst The input list to filter
- @return Only those elements of 'lst' that 'f' returns true for, in the
- same order as they appeared in 'lst'
-}
function filterM
Applicative m =>
m<[a]> ::= f::(m<Boolean> ::= a) lst::[a]
{
return
case lst of
| [] -> pure([])
| h :: t -> do {
cond::Boolean <- f(h);
rest::[a] <- filterM(f, t);
return if cond then h :: rest else rest;
}
end;
}

@{--
- Partition a list in two
-
Expand Down

0 comments on commit 4280d0a

Please sign in to comment.