-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow writing holes which are solved by BRAT #59
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so
- The number of comments suggests you've managed to break out a good sized chunk of code that is not too overwhelming :-), which is an achievement in itself - well done and thank you :-) 😁 👍
- There's a lot of hard stuff in the nat-inversion-building that I really haven't followed through the logic - I can only say that it looks plausible. However really I would prefer to do one of
- Add tests that cover all the cases and at least compile them down to Hugr. Then when we are able to execute them we suddenly gain a massive amount of assurance that we are actually building something sensible ;-) ;-)
- If these functions are not covered by tests, then leave them
error "TODO"
here, and move the logic into another PR which can remainWIP
until we do have tests (or at least, more time to think about them) - If the tests are only writable once we have
Fork
, lets leave themtodo
and move the code into Multi-threaded type inference #41 (they are quite localized - no change to APIs - so there shouldn't be much fallout from leaving them out of this PR)
brat/Brat/Checker.hs
Outdated
@@ -724,7 +731,7 @@ checkBody fnName body cty = do | |||
NoLhs tm -> pure (tm, (fcOf tm, fcOf tm)) | |||
Clauses (c :| cs) -> do | |||
fc <- req AskFC | |||
pure $ (WC fc (Lambda c cs), (bimap fcOf fcOf c)) | |||
pure (WC fc (Lambda c cs), bimap fcOf fcOf c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few drive-bys here. Not sure if these come from linting! Feel free to punt out into a separate trivial PR that I can just trivially hit approve...
brat/Brat/Checker.hs
Outdated
@@ -799,7 +806,7 @@ kindCheck ((hungry, k@(TypeFor m [])):unders) (Con c arg) = req (TLup (m, c)) >> | |||
-- the thing we *do* define kindOut as | |||
|
|||
(_, argUnders, [(kindOut,_)], (_ :<< _va, _)) <- | |||
next "" Hypo (S0, Some (Zy :* S0)) aliasArgs (REx ("type",Star []) R0) | |||
next "aliasargs" Hypo (S0, Some (Zy :* S0)) aliasArgs (REx ("type",Star []) R0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call this "kc_alias" and the other "load_alias" or something like that?
|
||
-- Both targets, we need to create the thing that they both derive from | ||
(InEnd bigTgt, [VPar (InEnd weeTgt)]) -> do | ||
(_, [(idTgt, _)], [(idSrc, _)], _) <- anext "numval id" Id (S0, Some (Zy :* S0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This case has no test coverage)
brat/Brat/Checker/SolvePatterns.hs
Outdated
@@ -266,9 +279,23 @@ unifyNum (NumValue lup lgro) (NumValue rup rgro) | |||
-- 2^k * x | |||
-- = 2^k * (y + 1) | |||
-- = 2^k + 2^k * y | |||
demandSucc (StrictMono k (Linear (VPar (ExEnd out)))) = do | |||
y <- mkPred out | |||
demandSucc _sm@(StrictMono _k (Linear (VPar (ExEnd _x)))) = error "Todo..." {-do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the whole of demandSucc
has no test coverage
halfTgt <- buildNatVal (NumValue 0 (StrictMonoFun (StrictMono 1 (Linear (VPar (toEnd tgt)))))) | ||
let half = nVar (VPar (toEnd halfTgt)) | ||
solveNumMeta (InEnd tgt) (n2PowTimes 1 half) | ||
pure (StrictMonoFun (StrictMono 0 (Linear (VPar (toEnd halfTgt))))) | ||
Full sm -> StrictMonoFun sm <$ demand0 (NumValue 0 (StrictMonoFun sm)) | ||
evenGro (StrictMonoFun (StrictMono n mono)) = pure (StrictMonoFun (StrictMono (n - 1) mono)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only line of evenGro
that has test coverage
Full sm -> StrictMonoFun sm <$ demand0 (NumValue 0 (StrictMonoFun sm)) | ||
evenGro (StrictMonoFun (StrictMono n mono)) = pure (StrictMonoFun (StrictMono (n - 1) mono)) | ||
|
||
-- Check a numval is odd, and return its rounded down half | ||
oddGro :: Fun00 (VVar Z) -> Checking (NumVal (VVar Z)) | ||
oddGro (StrictMonoFun (StrictMono 0 mono)) = case mono of | ||
Linear (VPar (ExEnd out)) -> mkPred out >>= demandEven | ||
Linear _ -> err . UnificationError $ "Can't force " ++ show n ++ " to be even" | ||
-- TODO: Why aren't we using `out`?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of oddGro
has test coverage
And other drive-by fixes pulled out from #59 --------- Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Alan Lawrence <[email protected]>
Co-authored-by: Alan Lawrence <[email protected]>
Closes #28 and #30