HM style type inference #3
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#3
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
I would document the design, current implementation progress, and limitations of the current implementation here.
Type Inference
Types
One can limit the possible valuation of type variables.
Unification
(This is only a high-level overview of it)
Note that when we unify a call with a function, we would instantiate the type variables in the function to fresh type variables first.
Some example typing rules:
expr1 = expr2
: unify the type ofexpr1
andexpr2
.foo.bar
: Create a fresh tyandpe variablex
, unify the type offoo
to record type variable{bar: x}
, and assign typex
tofoo.bar
.Control Flow
(for nac3embedded)
@kernel
/@portable
decorator.Implementation Progress
Limitations
The current implementation lacks certain features:
virtual
. We require an explicit cast for some more complicated cases.List[int], List[bool]
, instead we require something likeList[A]
where the range ofA
isint, bool
. This should not be a problem as we can implement this by normalizating user input, but error messages may be complicated.Some features would be implemented on the nac3embedded side, probably, so I can't say for now.
Todo:
with
,raise
andtry except
.is_concrete
with a recursive check to check for unbounded type variables. (but need tests)Should we close this and break it down into smaller Issues?
OK