Skip to content
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

Multi-threaded type inference #41

Draft
wants to merge 86 commits into
base: holes
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
04c52ac
Add "hoping" variables
croyzor Aug 19, 2024
3a1d6fe
Expand Free monad with Define and Yield
croyzor Aug 19, 2024
bf6cfcf
Add Define/Yield cases to handler functions
croyzor Aug 20, 2024
a6f00dd
Handle Yield in toplevel handler
croyzor Aug 20, 2024
4204c50
Add bang parsing
mark-koch Aug 20, 2024
3b8fdc1
Turn on ApplicativeDo
croyzor Aug 20, 2024
8f904bc
Add some dummy code for typechecking !
croyzor Aug 20, 2024
8b852a2
Revert "Add "hoping" variables"
croyzor Aug 20, 2024
77b92fe
Some parallelisation
croyzor Aug 20, 2024
3a1288d
Add hope set to monad
croyzor Aug 20, 2024
b979c70
Move occur check logic to Eval
croyzor Aug 20, 2024
a197fb2
misc changes
croyzor Aug 20, 2024
b115f84
[broken] update eqworker
croyzor Aug 20, 2024
ce1d1cf
Revert "[broken] update eqworker"
croyzor Aug 20, 2024
c064466
Add !,! test
croyzor Aug 20, 2024
b33f100
Rewrite typeEq
mark-koch Aug 20, 2024
c093ced
feat: Solve numbers that are just variables
croyzor Aug 21, 2024
7986539
typeEqRow returns sub-problems
acl-cqc Aug 21, 2024
7afa2c4
sequence_ -> traverse_ id
acl-cqc Aug 21, 2024
265a5b6
[broken] Build things to wire into solved hopes
croyzor Aug 21, 2024
2a360b6
Don't hide that error
croyzor Aug 21, 2024
6be252b
Fix typechecking for infer example
croyzor Aug 22, 2024
646f6f9
feat: Complain when we have remaining Nat-kinded holes
croyzor Aug 22, 2024
c2c8bbe
Incude file context in hopeSet
croyzor Aug 22, 2024
3765a8a
Allow comparing VInx
croyzor Aug 22, 2024
a22531b
Rewrite dynamic num refinements to work on srcs and tgts
croyzor Aug 22, 2024
af75834
Fix demandEven logic
croyzor Aug 22, 2024
283ccae
Flip that hypo node back around
croyzor Aug 22, 2024
0da9554
Rewrite computeMeta to do definition as well
croyzor Aug 23, 2024
2139140
SolvePatterns build fixes; unified.brat+infer.brat fail with non-clos…
acl-cqc Sep 17, 2024
78cc87c
Step0. Yield in getThunks
acl-cqc Aug 21, 2024
fb99b1a
Drop already-commented-out Helpers.hs export list
acl-cqc Sep 20, 2024
07c17ed
WIP two-stage check
acl-cqc Aug 21, 2024
23853e5
Add infer_thunks(,2).brat example; ...2 works but map body not checked
acl-cqc Aug 21, 2024
75e9017
checkClause returns subproblem (oops) - BOTH infer_thunks(,2) failing…
acl-cqc Sep 20, 2024
0f21ce7
Revert "checkClause returns subproblem (oops) - BOTH infer_thunks(,2)…
acl-cqc Sep 20, 2024
3bebd4c
WIP debug (shows we stop at [to_float] and never check to_float)
acl-cqc Aug 21, 2024
dce7f0f
Try just using *> rather than returning subproblem (tests build, 59 f…
acl-cqc Sep 17, 2024
5764083
WIP add request to Fork, but TODO captureOuterLocals (tests build but…
acl-cqc Sep 17, 2024
a2ebfcf
Add captureSets, AddCapture
acl-cqc Sep 17, 2024
2e4b14e
Plumb captureSet into CompilationState (never read), various Load.hs …
acl-cqc Sep 17, 2024
85ff9c7
captureOuterLocals routes captures via AddCapture, so Box VEnv always…
acl-cqc Aug 23, 2024
c90845c
And remove VEnv from Box
acl-cqc Aug 23, 2024
115c0fa
wip debug
acl-cqc Aug 23, 2024
c24ca0d
new: Add `Lluf` operation to the BRAT hugr extension
croyzor Sep 25, 2024
672392c
checkpoint b4 I break eerything
croyzor Sep 25, 2024
9f3faa8
A couple of unit tests with Fork/Define/Yield (add assertCheckingFail)
acl-cqc Aug 23, 2024
e694a8d
Reduce change, revert checkInputs/Outputs back to Checking, also chec…
acl-cqc Sep 17, 2024
2b73543
Add string description to Fork
acl-cqc Oct 1, 2024
251455b
TEMP remove failure tests
acl-cqc Sep 13, 2024
47f4c31
Fork outside Req, with both child computations (44 fails)
acl-cqc Oct 1, 2024
9dc4b0e
WIP remove debug
acl-cqc Oct 1, 2024
554bae2
Fix compilation crashing on empty captureSet
acl-cqc Sep 18, 2024
0bfcc27
Add isSkolem func, use in typeEqEta - TODO for now True for any outport
acl-cqc Sep 18, 2024
a4115fb
simpleCheck is Checking, allow to define hopes (except nat/int?!) and…
acl-cqc Sep 18, 2024
3b76be2
typeMap stores skolem-ness (always False ATM); TypeOf returns (EndTyp…
acl-cqc Sep 17, 2024
2ebb941
Inline only use of declareSrc
acl-cqc Sep 17, 2024
e0c7997
Declare takes Bool param (still always False)
acl-cqc Oct 1, 2024
45751ac
anext' allows setting Sources to be skolem
acl-cqc Sep 17, 2024
87270bf
implement isSkolem using TypeOf
acl-cqc Sep 18, 2024
2fcdd48
Common up Checking wrappers via 'wrapper' and 'wrapper2'
acl-cqc Sep 25, 2024
75a5ac0
print hopeset when blocked
acl-cqc Oct 1, 2024
9f1c6ff
Use defineEnd more
acl-cqc Oct 1, 2024
0808dab
Add mkYield, use it
acl-cqc Oct 1, 2024
a83de68
Remove concurrency-blocking -!s in makeBox (27 -> 24 fails)
acl-cqc Oct 1, 2024
98a5671
Remove howStuck, just use Unstuck (30 -> 27 fails)
acl-cqc Oct 1, 2024
db83ba9
typeEqEta shouldWait for ends inside nums as well, assert -> unless
acl-cqc Oct 1, 2024
710c931
Redo invertNatVal
croyzor Oct 3, 2024
3b36023
Refactor typeEqEta
acl-cqc Oct 4, 2024
3e15acc
typeEqEta: fast-path without blocking for both ends the same
acl-cqc Oct 4, 2024
a900ac4
typeEqEta shouldWait for ends inside nums as well, assert -> unless
acl-cqc Oct 1, 2024
3bf4f0b
Refactor typeEqEta
acl-cqc Oct 4, 2024
2c8f26b
typeEqEta: fast-path without blocking for both ends the same
acl-cqc Oct 4, 2024
42ef6d3
Call eval after resumption in simpleCheck
acl-cqc Oct 4, 2024
5b13e9d
Merge remote-tracking branch 'origin/main' into inference-wip/fork
acl-cqc Oct 4, 2024
43bcaf8
Merge remote-tracking branch 'origin/inference-wip/fork' into new/inf…
croyzor Oct 7, 2024
62332cf
Merge remote-tracking branch 'origin/craig/inference-wip/fork-and-nat…
acl-cqc Oct 7, 2024
5517854
SolvePatterns build fixes
acl-cqc Oct 7, 2024
48cd1e2
Merge remote-tracking branch 'origin/main' into inference-wip/fork (c…
acl-cqc Oct 21, 2024
4f8099b
Comment out mapVec
acl-cqc Oct 21, 2024
9203cb6
Fix checking of infer.brat w/note, add more. Compilation fails on Pow ?!
acl-cqc Oct 21, 2024
95dad0f
Revert "TEMP remove failure tests"
acl-cqc Oct 21, 2024
352e9f8
Fix infer.brat, no need to multiply by 2^0
acl-cqc Nov 22, 2024
3c96393
Merge remote-tracking branch 'origin/main' into inference-wip/fork
acl-cqc Nov 22, 2024
7c20289
Fix bad merge, check against HopeSet before vectorise not after
acl-cqc Nov 22, 2024
e6e37a9
(Try to) merge remote-tracking branch 'origin/holes' into inference-w…
acl-cqc Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Complain when we have remaining Nat-kinded holes
  • Loading branch information
croyzor committed Aug 22, 2024
commit 646f6f9011ece60ac2aaf74218bc837721200db7
17 changes: 14 additions & 3 deletions brat/Brat/Checker.hs
Original file line number Diff line number Diff line change
@@ -957,7 +957,7 @@ run :: VEnv
-> Namespace
-> Checking a
-> Either Error (a, ([TypedHole], Store, Graph, Namespace))
run ve initStore ns m =
run ve initStore ns m = do
let ctx = Ctx { globalVEnv = ve
, store = initStore
-- TODO: fill with default constructors
@@ -966,5 +966,16 @@ run ve initStore ns m =
, typeConstructors = defaultTypeConstructors
, aliasTable = M.empty
, hopeSet = S.empty
} in
(\(a,ctx,(holes, graph),ns) -> (a, (holes, store ctx, graph, ns))) <$> handler m ctx mempty ns
}
(a,ctx,(holes, graph),ns) <- handler m ctx mempty ns
let tyMap = typeMap $ store ctx
-- If the hopeSet has any remaining holes with kind Nat, we need to abort.
-- Even though we didn't need them for typechecking problems, our runtime
-- behaviour depends on the values of the holes, which we can't account for.
case S.toList $ S.filter (isNatKinded tyMap) (hopeSet ctx) of
[] -> pure (a, (holes, store ctx, graph, ns))
hs -> Left $ Err Nothing (RemainingNatHopes (show <$> hs))
where
isNatKinded tyMap e = case tyMap M.! e of
EndType Braty (Left Nat) -> True
_ -> False
8 changes: 5 additions & 3 deletions brat/Brat/Error.hs
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@ data ErrorMsg
| WrongModeForType String
-- TODO: Add file context here
| CompilingHoles [String]
| RemainingNatHopes [String]

instance Show ErrorMsg where
show (TypeErr x) = "Type error: " ++ x
@@ -161,9 +162,10 @@ instance Show ErrorMsg where
-- TODO: Make all of these use existing errors
show (UnificationError str) = "Unification error: " ++ str
show UnreachableBranch = "Branch cannot be reached"
show (CompilingHoles hs) = unlines ("Can't compile file with remaining holes": indent hs)
where
indent = fmap (" " ++)
show (CompilingHoles hs) = unlines ("Can't compile file with remaining holes":indent hs)
show (RemainingNatHopes hs) = unlines ("Expected to work out values for these holes:":indent (indent hs))

indent = fmap (" " ++)

data Error = Err { fc :: Maybe FC
, msg :: ErrorMsg
8 changes: 8 additions & 0 deletions brat/test/golden/error/remaining-nat-hopes.brat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
show(n :: #) -> []
show(_) = []

read([]) -> n :: #
read([]) = 42

bad :: []
bad = let _ = read([]) in show(!)
5 changes: 5 additions & 0 deletions brat/test/golden/error/remaining-nat-hopes.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Error in test/golden/error/remaining-nat-hopes.brat:
Expected to work out values for these holes:
In checking_check_defs_1_bad_2__2 0