Extend JsLIGO concrete and abstract syntax to support type parameters in functional expressions, i.e. const rev = <T>(...) => ...
Currently we can only write const rev : <T>(...) = (...) => ...
but the scope of T
is not the same as what we propose. See (type ...)
parameter in CameLIGO.
(see MR https://gitlab.com/ligolang/ligo/-/merge_requests/2315)
Refactor the abstraction of the switch
statement:
There is a MR from Sander (link) about return
statements, which already improves the current hack: make that MR ready.
There are some catch-all clauses introduced try and remove the use of a catch-all clause.
Remove variant types and match
and replace them with discriminate unions and switch
, but a simple removal would not do because, for instance, switch
is a statement, whereas match
is an expression.
let v = Some(1)
const option_value = match(v,
{ Some: (v) => v
, None: () => failwith "None" }
)
// You cannot do this because
const option_value_fn = (v) => {
switch(v.kind) {
case "Some": return v.data
case "None": failwith "None"
}
}
const option_value2 = option_value_fn(v)
default
case in discriminated unions don’t work
type shape =
{ kind: "square", size: int }
| { kind: "rectangle", width: int, height: int };
const area = (s: shape) => {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
default: return -1;
}
}
Allow p.x = e
instead of p = {..p, x:e}
for let
variables p
(see MR https://gitlab.com/ligolang/ligo/-/merge_requests/2309
and https://gitlab.com/ligolang/ligo/-/merge_requests/2331)
Introduce function
keyword
(see https://gitlab.com/ligolang/ligo/-/merge_requests/2661)
Allow list([...xs, ...ys, ...zs])
for list concatenation instead of calling List.append
Allow let m = Map.empty; m.set('a', 12);
instead of let m = Map.empty; m = Map.update('a', 12, m);
Make record update work as an instruction (see https://gitlab.com/ligolang/ligo/-/merge_requests/2661)
let p = { x: 0, y : 0};
p = {...p, x:1};
Fix block scopes in jsligo
// const & let have block scope
type t = {
x : int ,
y : string,
kind : string
}
const main = (_: t, s: int): [list<operation>, int] => {
const p = { x : 2 , y : "foo", kind : "aaa" }
let p = { ...p, x: 1}; // This should be an error
return [list([]), 1]
}
// Same for
let p = { x : 2 , y : "foo", kind : "aaa" }
let p = { ...p, x: 1};
For nullary constructors consider the following syntax
type t = "none" | { kind : "some"; value : int }