Created
March 18, 2016 02:24
-
-
Save j14159/aa869c3d04cac59e567f to your computer and use it in GitHub Desktop.
Progress on list type inferencing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_test_() -> | |
[?_assertMatch({{t_list, t_float}, _}, | |
top_typ_of("1.0 : []")), | |
?_assertMatch({{t_list, t_int}, _}, | |
top_typ_of("1 : 2 : []")), | |
?_assertMatch({error, _}, top_typ_of("1 : 2.0 : []")), | |
?_assertMatch({{t_arrow, | |
[{unbound, A, _}, {t_list, {unbound, A, _}}], | |
{t_list, {unbound, A, _}}}, _}, | |
top_typ_of("f x y = x : y")), | |
?_assertMatch({{t_arrow, [{t_list, t_int}], t_int}, _}, | |
top_typ_of( | |
"f list = match list with\n" | |
"| h : t -> h + 1")), | |
%% Ensure that a '_' in a list nested in a tuple is renamed properly | |
%% so that one does NOT get unified with the other when they're | |
%% potentially different types: | |
?_assertMatch({{t_arrow, | |
[{t_tuple, [{t_list, t_int}, {unbound, _, _}, t_float]}], | |
{t_tuple, [t_int, t_float]}}, _}, | |
top_typ_of( | |
"f list_in_tuple =\n" | |
" match list_in_tuple with\n" | |
" | (h : 1 : _ : t, _, f) -> (h, f +. 3.0)")) | |
]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment