Suppose we want to clean up all TODO
s in a branch before merging. We can check
for TODO
s introduced with
git diff master | rg '(\+|-).*TODO'
Thence:
- , opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
- , opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
- -- TODO The RewriteEnv should just take ClashOpts.
- -- TODO This was a call to makeCachedU, but since there was no variation
- -- TODO Should tm3 be done async / added to the job queue when it's made?
- -- TODO Given we now keep transformCounters, this should just be 'fold'
- -- TODO Although we're locking access to the history file, entries
+-- TODO I think isWorkFree only needs to exist within the rewriting monad, and
However this is inconvenient; it strips file names and line numbers, making whatever one uncovers harder to address.
One can handle this with Awk but I think it is instructive to use Jacinda here, both to show how to do this in a functional style and to face Jacinda's limitations.
We will create an expression that is capable of tracking state across lines using a scan, viz.
@include'prelude/fn.jac'
@include'lib/maybe.jac'
fn mMatch(str, re) :=
if str ~ re
then Some str
else None;
fn step(needle, ctx, line) :=
let
val fpCtx ≔ line ~* 1 /diff --git\s+([^\s]+)/
val mLine ≔ mMatch line needle
in (alternative (ctx->1) fpCtx.mLine) end;
fn process(x) :=
let
val fpCtx ≔ fromMaybe 'WARN' (x->1)
val line ≔ (λl. sprintf'%s: %s' (fpCtx.l))"(x->2)
in line end;
process:?(step/(\+|-).*TODO/)^(None.None)$0
Note that we need lib/maybe.dck
for alternative
, Haskell's (<|>)
.
We get:
clash-lib/src/Clash/Driver/Types.hs: - , opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
clash-lib/src/Clash/Driver/Types.hs: + , opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
clash-lib/src/Clash/Normalize.hs: - -- TODO The RewriteEnv should just take ClashOpts.
clash-lib/src/Clash/Normalize/Util.hs: + -- TODO This was a call to makeCachedU, but since there was no variation
clash-lib/src/Clash/Normalize/Util.hs: + -- TODO Should tm3 be done async / added to the job queue when it's made?
clash-lib/src/Clash/Rewrite/Types.hs: - -- TODO Given we now keep transformCounters, this should just be 'fold'
clash-lib/src/Clash/Rewrite/Util.hs: + -- TODO Although we're locking access to the history file, entries
clash-lib/src/Clash/Rewrite/WorkFree.hs: +-- TODO I think isWorkFree only needs to exist within the rewriting monad, and
My guess is that this is more prolix than the equivalent in Awk.
Moreover, Jacinda suffers
from the lack of user-defined operators; I would like ~?
in place of mMatch
and something like <|>
in place of alternative
.