Conversation
|
|
||
| :todo | ||
| id of { x: 1 } | ||
| //│ Type: Str |
There was a problem hiding this comment.
The { x: 1 } is elaborated to a Tup with an ascription ["x": 1].
It is typed as id("x") since the ascription is ignored.
There was a problem hiding this comment.
I wonder why this happens. Are you sure it's an ascription? It should elaborate to a RecordField
There was a problem hiding this comment.
It is a Fld with the field asc set as Some(1).
Similarly, id of { x: 1, y: 2 } reports incorrect number of arguments. It is an error in basic/Records.mls originally.
There was a problem hiding this comment.
Actually it's working "as intended". Currently, curly braces are equivalent to an indented block. Here one would need normal parentheses instead
id of (x: 1)Co-authored-by: Lionel Parreaux <lionel.parreaux@gmail.com>
| //│ Type: ['x, 'scrut, 'eff, 'cons] -> 'x ->{'eff} 'cons | ||
| //│ Where: | ||
| //│ 'x <: ¬Int ∨ Int | ||
| //│ 'x#Int ∨ ∧ ⊥<:'eff ∧ 'scrut<:Int ∧ Int<:Int ∧ Str<:'cons | ||
| //│ Int ∧ 'x <: 'scrut | ||
| //│ 'scrut#Int ∨ ∧ ⊥<:'eff ∧ 'scrut<:Int ∧ Int<:Int ∧ Str<:'cons |
There was a problem hiding this comment.
For patmat without default cases, can't we just implicitly add a case that matches the negations of all previous patterns and constrains the scrutinee to be Bot?
There was a problem hiding this comment.
(This inferred type scheme, like the original one from BbML, misinterprets the patmat as being exhaustive, thus allowing 'x = ~Int as a – spurious – solution.)
|
|
||
| run(x `=> id(x) `* x) | ||
| //│ Type: Int -> ⊥ | ||
| //│ Type: ⊤ -> ⊥ |
| //│ Type: Prod[Tru, Tru] | Prod[Fls, Fls] | ||
|
|
||
| :e | ||
| { fst: y(x => x), snd: y(x => x) } as [ fst: Tru, snd: Tru ] | [ fst: Fls, snd: Fls ] |
There was a problem hiding this comment.
Any reason why you use a record on the LHS and tuples on the RHS? Why are the RHS' treated like records? They should be one-element arrays. Remember that [ fst: Tru, snd: Tru ] is syntax sugar for [ (fst: Tru, snd: Tru) ].
| fun y: Any -> Tru | Fls | ||
| //│ Type: ⊤ | ||
|
|
||
| prod(y(x => x), y(x => x)) as Prod[Tru, Tru] | Prod[Fls, Fls] |
There was a problem hiding this comment.
How come this type checks? Shouldn't it be Prod[Tru | Fls, Tru | Fls]?
There was a problem hiding this comment.
Because classes are merged in union. It is actually Prod[Tru | Fls, Tru | Fls] here.
The example using record does not type check.
The original paper uses tuple and type checks:
There was a problem hiding this comment.
Wait why does it type check in the original paper, then? Do they merge the union?
There was a problem hiding this comment.
If I understand correctly, it is because both
There was a problem hiding this comment.
Wow... that seems a bit crazy. Do they keep track of equalities between terms at the type level? Or what other sorcery do they use? It sounds very expensive.
There was a problem hiding this comment.
I think they use the maximal sharing canonical forms to do the type checking, so the expression is something like
bind a = y in
bind b = x => x in
bind c = a(b) in
bind d = (c, c) in
d
Where c can be either True or False.
There was a problem hiding this comment.
Ah, right; I remember seeing this. Presumably, we could do the same thing, but that would probably not be worth it. Please document this as comments on the test case.
2025-02-26 TODO:
dsscollectTVs)(for now use temporary syntaxfun foo: ["x": Int, "y": Int])2025-03-06 TODO:
Later:
2025-03-13 TODO:
Later:
:logicSub