Both current methods of decomposing values (case expresssions and data constructor field selection expressions) cause a value to be evaluated to weak head normal form (WHNF) - i.e. so the top level constructor of the value is known. The new syntax will allow pattern matching on the LHS of a LET definition e.g.:
// list cons patterns:
public foo3 = let
a:b = [3];
in
a;
// tuple patterns:
public foo4 = let
(a, b, c) = (b, c, 1.0);
in
a+b+c;
// record patterns:
public foo5 = let
{a} = {a = "foo"};
in
a;
public foo6 = let
{_ | a} = {a = "foo", b = "bar"};
in
a;
The difference between this syntax and case or field selection expressions is that the RHS of the LET definition is not evaluated until some value in the LHS is evaluated.
More details on this feature will be published soon.
1 comment:
Hello. I really think that such sites like yours are very important for self-development for everybody. Thank you for yours work.
Post a Comment