Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
8192fb7
Spec out new Record type with pattern matching
ChrisPenner Apr 15, 2025
7545cbb
Add missing cases for new runtime Records
ChrisPenner Jan 22, 2026
8f1fe35
Checkpoint
ChrisPenner Jan 22, 2026
b275831
Remove FRec from functions
ChrisPenner Jan 22, 2026
c59f505
WIP
ChrisPenner Jan 22, 2026
f94473c
WIP
ChrisPenner Jan 23, 2026
0d2ed95
Compiling, but with a lot of "error"s
ChrisPenner Jan 23, 2026
7d3e2a0
Remove Reference from record term ast
ChrisPenner Jan 23, 2026
74f2546
More switching Record to not have a reference
ChrisPenner Jan 23, 2026
eea99c9
Finish removing Reference from Record, and swap it to use a Map
ChrisPenner Jan 23, 2026
7b74da8
Wire in record literal parser
ChrisPenner Jan 23, 2026
ff6a989
Record parser
ChrisPenner Jan 23, 2026
19ea4ff
Add Record Type F
ChrisPenner Jan 23, 2026
6d4feae
Record type hashing
ChrisPenner Jan 23, 2026
e094006
Attempt to do Kind Inference for record fields
ChrisPenner Jan 23, 2026
6489447
Fix synhashing of records
ChrisPenner Jan 23, 2026
de1c2b2
Compiling after adding record type F
ChrisPenner Jan 23, 2026
ea7bb13
Implement record type synthesis
ChrisPenner Jan 23, 2026
c6167ed
Better record type printing
ChrisPenner Jan 23, 2026
28b8b29
Typechecking is _running_, but incorrect
ChrisPenner Jan 23, 2026
7b3583d
Implement unification on Records
ChrisPenner Jan 23, 2026
394da37
More missing field error messages
ChrisPenner Jan 24, 2026
b7e5bf9
Better error messages
ChrisPenner Jan 24, 2026
8e3316d
Fill out Record packing
ChrisPenner Jan 26, 2026
bf9d89e
coalesce wanted in Records
ChrisPenner Jan 26, 2026
ce16035
Switch from BLDR to a Record Pack func app
ChrisPenner Jan 26, 2026
249d36c
Moar serialization
ChrisPenner Jan 27, 2026
369c93d
More threading in rec Schema discovery
ChrisPenner Jan 27, 2026
41f3691
Add record schema numbering
ChrisPenner Jan 28, 2026
07e6db4
Murmur hashing for record values
ChrisPenner Jan 28, 2026
6d2dc86
Record v5 serialization
ChrisPenner Jan 28, 2026
357785b
Fix RecordC vs RecordG
ChrisPenner Jan 28, 2026
c4d2727
Pass in rec schema lookups
ChrisPenner Jan 28, 2026
b385c4f
Add BiMap to utils
ChrisPenner Jan 28, 2026
10b0988
Use BiMap
ChrisPenner Jan 28, 2026
39a42be
Simplify error handling for runtime exceptions
ChrisPenner Jan 28, 2026
f501c96
Fix term printer for records
ChrisPenner Jan 28, 2026
5059500
Record Pattern parser
ChrisPenner Jan 28, 2026
c002069
First attempt at Record field desugaring
ChrisPenner Jan 28, 2026
c6b7654
Fix (?) record pattern match desugaring
ChrisPenner Jan 28, 2026
bd58726
Skip pattern match constraint solving for now
ChrisPenner Jan 28, 2026
a31db74
Fix up LSP queries
ChrisPenner Jan 29, 2026
eff2dfc
Implement some pattern match type-checking errors
ChrisPenner Jan 29, 2026
8760d9c
Implement record pattern pretty printing
ChrisPenner Jan 29, 2026
c1a4c03
Don't depend on pattern scrutinee type before we solve it
ChrisPenner Jan 29, 2026
de4c709
Add some notes
ChrisPenner Jan 30, 2026
9356719
Implement record type parser
ChrisPenner Jan 30, 2026
1903f63
Add completeness pragma for Effect''
ChrisPenner Feb 2, 2026
6b41c33
Implement instantiateL and equate0 for records
ChrisPenner Feb 2, 2026
988b3f2
Notes from typechecking paper
ChrisPenner Feb 2, 2026
546a430
instantiateR for records
ChrisPenner Feb 2, 2026
1cea3b8
Add a few missing Record cases in typechecker
ChrisPenner Feb 3, 2026
732f78f
Circumvent pattern-match coverage checker. Remove this commit and fix it
ChrisPenner Feb 3, 2026
d19d20f
WIP pattern match runtime
ChrisPenner Feb 3, 2026
0dfb37b
Add ANF cases for record pattern-matching
ChrisPenner Feb 4, 2026
a98d0df
More ANF record pattern matching
ChrisPenner Feb 4, 2026
cf480e5
Add RecUnpack instr
ChrisPenner Feb 4, 2026
289bc07
Simple runtime pattern matching is working
ChrisPenner Feb 5, 2026
6ceb411
Working pattern unpacking for fully specified record patterns
ChrisPenner Feb 5, 2026
c3d06ec
Remove old debug statements
ChrisPenner Feb 5, 2026
b2fcefd
Add unexpected field error
ChrisPenner Feb 5, 2026
577fd3d
Store actual HashMap in runtime Closure
ChrisPenner Feb 5, 2026
7ed9786
Attempt to fix lsp errors
ChrisPenner Feb 5, 2026
999eb87
Add new records transcript
ChrisPenner Feb 5, 2026
f278efc
Update transcripts
ChrisPenner Feb 5, 2026
dbd4739
Implement `{field : f | ...}` field subset typechecking
ChrisPenner Feb 5, 2026
65c331b
Fix imports
ChrisPenner Feb 19, 2026
d7f1156
Rewrite Emit monad
ChrisPenner Feb 19, 2026
2bef918
Finish rewriting Emit monad
ChrisPenner Feb 20, 2026
ca7483a
Start threading RFM initialization
ChrisPenner Feb 20, 2026
d7fe4a9
Better RecordFieldMapping builder
ChrisPenner Feb 24, 2026
20eb2de
WIP
ChrisPenner Feb 24, 2026
3bdafe5
Compiling with field-refs
ChrisPenner Feb 24, 2026
4cd43b6
Working again, now with FieldRefs
ChrisPenner Feb 24, 2026
f17c0d0
Fix badly recursive case in term printer
ChrisPenner Feb 26, 2026
cf4720a
Fix up groupCases
ChrisPenner Feb 26, 2026
24be717
Fix folding over vs in record literal
ChrisPenner Feb 26, 2026
54d7643
automatically run ormolu
ChrisPenner Feb 26, 2026
28e0ff7
Transcript updates
ChrisPenner Sep 28, 2026
1684501
Transcript updates
ChrisPenner Sep 28, 2026
2fe90e6
Implement Universal compare on records
ChrisPenner Sep 28, 2026
09ef8d2
PR Cleanup
ChrisPenner Sep 28, 2026
434d9c5
Update universals in transcript
ChrisPenner Sep 28, 2026
67c110f
Records: fix ANF tag deserialization and delimit record hashes
ChrisPenner Sep 28, 2026
1ea4bf1
Records: fix nested record patterns and correct record type errors
ChrisPenner Sep 28, 2026
90d0f63
Records: support refutable patterns inside record patterns
ChrisPenner Sep 28, 2026
6f98119
Records: reject duplicate field names
ChrisPenner Sep 28, 2026
540321d
Records: order record fields by name, and implement value reflection
ChrisPenner Sep 29, 2026
bc84e02
Records: print real field names in runtime errors
ChrisPenner Sep 29, 2026
ff6525a
Records: add field projection with `r@x`
ChrisPenner Sep 29, 2026
248b1eb
Records: support record patterns in `@rewrite case` rules
ChrisPenner Sep 29, 2026
44903e5
Merge trunk into the records branch
ChrisPenner Sep 29, 2026
cbfab33
Records: repair the runtime test suite
ChrisPenner Sep 29, 2026
e44404b
Records: make record patterns compare equal to each other
ChrisPenner Sep 29, 2026
0f01c31
Disable libffi tests on mac, where system libffi doesn't behave.
ChrisPenner Sep 29, 2026
cbc8846
Bump codebase version
ChrisPenner Oct 1, 2026
e0368dd
Records: row variables, rec@foo.set, and record sections
pchiusano Oct 12, 2026
fdf1ae9
Better inference of multiple projections
pchiusano Oct 13, 2026
281dd14
Record types in negative position now have an implicit wildcard
pchiusano Oct 13, 2026
42b2991
Records: repair the ANF test suite for FRecSet
pchiusano Oct 13, 2026
03fe9bc
fix formatting
pchiusano Oct 13, 2026
0503949
Better variable names for inferred row types
pchiusano Oct 13, 2026
60e2fd0
Records: drop vacuous row variables from inferred types
pchiusano Oct 13, 2026
a3df53e
commit proofs
pchiusano Oct 13, 2026
c938f09
added multi-field set and nested set syntax
pchiusano Oct 13, 2026
7255e69
proofs
pchiusano Oct 13, 2026
7832ae9
tweak transcript
pchiusano Oct 13, 2026
1ec6b83
tweak transcript, update proofs
pchiusano Oct 13, 2026
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
Add a few missing Record cases in typechecker
  • Loading branch information
ChrisPenner committed Feb 26, 2026
commit 1cea3b8be4693376d5773dc57b8f654f6fe10f6f
18 changes: 17 additions & 1 deletion parser-typechecker/src/Unison/Typechecker/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,7 @@ ungeneralize' t = pure ([], t)
-- de-generalized, and replaces simple freshening of the
-- polymorphic variable.
tweakEffects ::
forall v loc.
(Var v) =>
(Ord loc) =>
TypeVar v loc ->
Expand All @@ -2119,6 +2120,9 @@ tweakEffects v0 t0
appendContext (existential <$> vs)
pure (vs, ABT.substInheritAnnotation v0 (typ vs) ty)

rewrite :: Maybe Bool
-> ABT.Term Type.F (TypeVar v loc) a
-> MT v loc (Result v loc) ([v], Type.Type (TypeVar v loc) a)
rewrite p ty
| Type.ForallNamed' v t <- ty,
v0 /= v =
Expand All @@ -2143,6 +2147,9 @@ tweakEffects v0 t0
(vfs, f) <- rewrite p f
(vxs, x) <- rewrite Nothing x
pure (vfs ++ vxs, Type.app (loc ty) f x)
| Type.Record' fields <- ty = do
(vs, fields') <- getCompose $ for fields (Compose . rewrite p)
pure (vs, Type.record (loc ty) fields')
| otherwise = pure ([], ty)
where
a = loc ty
Expand Down Expand Up @@ -2171,6 +2178,7 @@ isVariant u = walk True
walk var i && walk var o && all (walk var) es
walk var (Type.App' f x) = walk var f && walk False x
walk var (Type.Var' v) = u /= v || var
walk var (Type.Record' fields) = all (walk var) fields
walk _ _ = True

skolemize ::
Expand Down Expand Up @@ -2470,6 +2478,9 @@ discardCovariant vars gens ty =
| Just vs <- checkVarianceWith vars f,
length vs == length xs =
keepVarsT pos f <> foldMap (keepVarsV pos) (zip vs xs)
keepVarsT pos (Type.Record' fields) =
-- TODO: Is this right?
foldMap (keepVarsT pos) fields
keepVarsT _ t = foldMap exi $ Type.freeVars t

exi (TypeVar.Existential _ v) = Set.singleton v
Expand Down Expand Up @@ -2578,6 +2589,9 @@ relax' vars nonArrow fv = rebuild True
Just (Pos : _) -> rebuild False x
_ -> pure x
pure $ Type.app loc f x
| Type.Record' fields <- t = do
fields <- traverse (rebuild False) fields
pure $ Type.record loc fields
| top, nonArrow = ftv loc <&> \tv -> Type.effect loc [tv] t
| otherwise = pure t
where
Expand All @@ -2604,7 +2618,7 @@ checkWantedScoped exact want m ty =
-- updated set.
--
-- The Maybe argument determines whether an exact ability match is
-- required for function maches. This is to check for suspicious
-- required for function matches. This is to check for suspicious
-- ability handler situations like:
--
-- foo : '{X, Y} r -> r
Expand Down Expand Up @@ -2717,6 +2731,8 @@ checkWanted exact want (Term.List' es) lty
Foldable.foldlM f want es
where
bexact = isJust exact
-- TODO: Do we need a case for Term.Record'?
-- I don't think so
Comment thread
ChrisPenner marked this conversation as resolved.
Resolved
checkWanted _ want e t = do
(u, wnew) <- synthesize e
ctx <- getContext
Expand Down