hkust-taco / mlscript

The MLscript programming language. Functional and object-oriented; structurally typed and sound; with powerful type inference. Soon to have full interop with TypeScript!
https://hkust-taco.github.io/mlscript
MIT License
175 stars 27 forks source link

UCS tracking issue #151

Open LPTK opened 2 years ago

LPTK commented 2 years ago

Issue to track the parts of the UCS implementation that are still incomplete or wrong – please update with more cases as you find them.

Translation

Locations

Reporting

LPTK commented 1 year ago
LPTK commented 1 year ago
:NewParser
:NewDefs

module Nil
class Cons[A](head: A, tail: Cons[A] | Nil)
//│ module Nil()
//│ class Cons[A](head: A, tail: Cons[A] | Nil)

// FIXME
fun filtermap(f, xs) = if xs is
  Nil then Nil
  Cons(y, ys) and f(ys) is
    false then filtermap(f, ys)
    true then Cons(y, filtermap(f, ys))
    [true, z] then Cons(y, filtermap(f, ys))
//│ ╔══[ERROR] identifier not found: ys
//│ ║  l.26:      Cons(y, ys) and f(ys) is
//│ ╙──                             ^^
//│ ╔══[ERROR] Type mismatch in application:
//│ ║  l.26:      Cons(y, ys) and f(ys) is
//│ ║                             ^^^^^^^^
//│ ║  l.27:        false then filtermap(f, ys)
//│ ║           ^^^^^^^^^
//│ ╟── reference of type `false` is not an instance of type `number`
//│ ║  l.27:        false then filtermap(f, ys)
//│ ╙──             ^^^^^
//│ ╔══[ERROR] Type mismatch in application:
//│ ║  l.26:      Cons(y, ys) and f(ys) is
//│ ║                             ^^^^^^^^
//│ ║  l.27:        false then filtermap(f, ys)
//│ ║           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//│ ║  l.28:        true then Cons(y, filtermap(f, ys))
//│ ║           ^^^^^^^^
//│ ╟── reference of type `true` is not an instance of type `number`
//│ ║  l.28:        true then Cons(y, filtermap(f, ys))
//│ ╙──             ^^^^
//│ ╔══[ERROR] type identifier not found: Tuple#2
//│ ╙──
//│ fun filtermap: ((error | Cons['A] | Nil) -> number & (Cons['A] | Nil) -> error, Cons['A0] | Nil,) -> (Cons['A1] | Nil | error)
//│   where
//│     'A := 'A0
//│     'A0 <: nothing
//│ Code generation encountered an error:
//│   unknown match case: Tuple#2

module True
module False
//│ module True()
//│ module False()

class Pair[A, B](lhs: A, rhs: B)
//│ class Pair[A, B](lhs: A, rhs: B)

fun filtermap(f, xs) = if xs is
  Nil then Nil
  Cons(y, ys) then if f(y) is
    True then filtermap(f, ys)
    False then Cons(y, filtermap(f, ys))
    Pair(True, z) then Cons(z, filtermap(f, ys))
//│ fun filtermap: ('head -> (False | Pair[anything, 'A] | True), Cons['head] | Nil,) -> (Cons['A] | Nil)
//│   where
//│     'head <: 'A
chengluyu commented 1 year ago
chengluyu commented 1 year ago
chengluyu commented 1 year ago
LPTK commented 1 year ago
LPTK commented 9 months ago