Files
mgmt/lang/interpret_test/TestAstFunc2/tricky-unification1/main.mcl
James Shubin 3968c12947 lang: funcs: simplepoly: Support variant's in func definitions
This adds support for variant types in the simple poly definitions. It
is recommended that you avoid using these as much as possible, because
they're a bit harder for the type unification to solve for them. The way
this works is that these functions look at the available input types and
then generate a (recursive) set of invariants which might hold true. It
filters out any impossible ones, which is where this variant matching is
done. It's less likely that you'll get a solution with this mechanism,
but it is possible.
2021-05-23 20:03:10 -04:00

5 lines
142 B
Plaintext

import "fmt"
$ints = [13, 42, 0, -37,]
$l int = len($ints) # return type is known statically!
test fmt.printf("len is: %d", $l) {} # len is 4