Commit 9a8eface authored by Pietro Abate's avatar Pietro Abate
Browse files

Merge branch 'master' of https://git.cduce.org/cduce

parents 79ba4759 535d0389
......@@ -310,6 +310,7 @@ let catch_exn ppf_err exn =
Format.fprintf ppf_err "@."
let parse rule input =
Ulexer.toplevel := !toplevel;
try Parser.localize_exn (fun () -> rule input)
with e -> Parser.sync (); raise e
......
......@@ -138,6 +138,8 @@ module L = Ulexing
exception Error of int * int * string
let toplevel = ref false
let error i j s = raise (Error (i,j,s))
(* Buffer for string literals *)
......@@ -182,6 +184,8 @@ let regexp ncname_char =
let regexp ncname = ( xml_letter ncname_char* ) | ('_' ncname_char+)
let regexp qname = (ncname ':')? ncname
(* Should be [^ xml_letter ] *)
let regexp not_xml_letter = [^ 'A'-'Z' 'a'-'z' '0'-'9' '_' ]
let illegal lexbuf =
error
......@@ -276,7 +280,8 @@ and token2 = lexer
string (L.lexeme_start lexbuf) '"' lexbuf;
let s = get_stored_string () in
return_loc start (L.lexeme_end lexbuf) (STRING s)
| "'" [^ '\'']+ "'" ->
| "'" "\\"? _ "'--'" "\\"? _ "'"
| "'" [^ '\'']+ "'" not_xml_letter ->
L.rollback lexbuf;
(fun _ -> lexer
| "'" -> let start = L.lexeme_start lexbuf in
......@@ -284,9 +289,9 @@ and token2 = lexer
let s = get_stored_string () in
return_loc start (L.lexeme_end lexbuf) (STRING2 s)
| _ -> assert false) () lexbuf
| "('" ncname ")" ->
| "'" ncname ->
let s = L.utf8_lexeme lexbuf in
let s = String.sub s 2 (String.length s - 3) in
let s = String.sub s 1 (String.length s - 1) in
return lexbuf (PTYPE s)
| "(*" ->
in_comment := true;
......@@ -303,18 +308,60 @@ and token2 = lexer
| _ ->
illegal lexbuf
and unescape s start =
let rec aux acc start = function
| "" -> acc
| s ->
let len = String.length s in
if s.[0] = '\\' then if len != 1
then aux (acc ^ String.make 1 s.[1]) start (String.sub s 2 (len - 2))
else error start (start+1) "Unterminated string"
else
let tmp = String.sub s 1 (len - 1) in
aux (acc ^ String.make 1 s.[0]) start tmp in
aux "" start s
and token2toplevel = lexer
| xml_blank+ -> token2toplevel lexbuf
| qname ->
let s = L.utf8_lexeme lexbuf in
return lexbuf (IDENT s)
| ncname ":*" ->
let s = L.utf8_sub_lexeme lexbuf 0 (L.lexeme_length lexbuf - 2) in
return lexbuf (ANY_IN_NS s)
| ".:*" ->
return lexbuf (ANY_IN_NS "")
| '-'? ['0'-'9']+ ->
return lexbuf (INT (L.utf8_lexeme lexbuf))
| [ "<>=.,:;+-*/@&{}()|?`!$" ]
| "->" | "::" | ";;" | "--" | "//" | "/@" | ":=" | "\\" | "++"
| "<=" | ">=" | "<<" | ">>" | "||" | "&&" | "**" | "_"
| ".."
| ["?+*"] "?" | "#" ->
return lexbuf (KEYWORD (L.utf8_lexeme lexbuf))
| "[" -> in_brackets := !in_brackets + 1;
return lexbuf (KEYWORD (L.utf8_lexeme lexbuf))
| "]" -> in_brackets := !in_brackets - 1;
return lexbuf (KEYWORD (L.utf8_lexeme lexbuf))
| '"' ->
let start = L.lexeme_start lexbuf in
string (L.lexeme_start lexbuf) '"' lexbuf;
let s = get_stored_string () in
return_loc start (L.lexeme_end lexbuf) (STRING s)
| "'" "\\"? _ "'--'" "\\"? _ "'"
| "'" [^ "\n\'"]+ "'" not_xml_letter ->
L.rollback lexbuf;
(fun _ -> lexer
| "'" -> let start = L.lexeme_start lexbuf in
string (L.lexeme_start lexbuf) '\'' lexbuf;
let s = get_stored_string () in
return_loc start (L.lexeme_end lexbuf) (STRING2 s)
| _ -> assert false) () lexbuf
| "'" ncname ->
let s = L.utf8_lexeme lexbuf in
let s = String.sub s 1 (String.length s - 1) in
return lexbuf (PTYPE s)
| "(*" ->
in_comment := true;
comment (L.lexeme_start lexbuf) lexbuf;
in_comment := false;
token2toplevel lexbuf
| "/*" ->
in_comment := true;
tcomment (L.lexeme_start lexbuf) lexbuf;
in_comment := false;
token2toplevel lexbuf
| eof ->
return lexbuf EOI
| _ ->
illegal lexbuf
and comment start = lexer
| "(*" ->
......@@ -353,7 +400,8 @@ and string start endchar = lexer
| eof -> error start (start+1) "Unterminated string"
| _ -> store_lexeme lexbuf; string start endchar lexbuf
let token lexbuf = if !in_brackets = 0 then token lexbuf else token2 lexbuf
let token lexbuf = if !in_brackets = 0 then token lexbuf
else if !toplevel then token2toplevel lexbuf else token2 lexbuf
let lexbuf = ref None
let last_tok = ref (KEYWORD "DUMMY")
......
......@@ -13,6 +13,8 @@ type token =
exception Error of int * int * string
val toplevel : bool ref
module Loc : Loc with type t = int * int
module Token : Token with module Loc = Loc and type t = token
module Error : Error
......
......@@ -80,9 +80,9 @@ let test_constraint_ops () = [
"prod neg",mk_prod [N("Int",V "B");N("Bool",V "B")], mk_pp (N("Int | Bool",V "B"));
"prod var",mk_prod [N("('B)",V "A");P(V "B","Bool | Int")],
"prod var",mk_prod [N("'B",V "A");P(V "B","Bool | Int")],
mk_union_res
[N("('B)",V "A");P(V "B","Bool | Int")]
[N("'B",V "A");P(V "B","Bool | Int")]
[];
"empty", mk_union [P(V "A","Empty")] [P(V "A","Empty")], mk_pp (P(V "A","Empty"));
......@@ -134,30 +134,30 @@ let norm_tests () = [
"(Int,Int)", "Empty", Tallying.CS.unsat;
"Int -> Int", "Empty" , Tallying.CS.unsat;
"Bool -> Bool","Int -> ('A)", Tallying.CS.unsat;
"Bool -> Bool","Int -> 'A", Tallying.CS.unsat;
"Int", "Bool", Tallying.CS.unsat;
"Int", "Empty", Tallying.CS.unsat;
"[] -> []","Int -> ('A)", Tallying.CS.unsat;
"[] -> []","Int -> 'A", Tallying.CS.unsat;
"Any", "Empty", Tallying.CS.unsat;
"Empty", "Empty", Tallying.CS.sat;
"(('A) -> Bool)", "(('B) -> ('B))", mk_s [
"('A -> Bool)", "('B -> 'B)", mk_s [
[P(V "B","Empty")];
[N("('B)",V "A");N("Bool",V "B")]
[N("'B",V "A");N("Bool",V "B")]
];
"('B)", "('A)", mk_s [[N("('B)",V "A")]];
"('B)", "Empty", mk_s [[P(V "B","Empty")]];
"Int", "('B)", mk_s [[N("Int",V "B")]];
"Int", "(('A) | ('B))", mk_s [[N("Int \\ ('B)",V "A")]];
"'B", "'A", mk_s [[N("'B",V "A")]];
"'B", "Empty", mk_s [[P(V "B","Empty")]];
"Int", "'B", mk_s [[N("Int",V "B")]];
"Int", "('A | 'B)", mk_s [[N("Int \\ 'B",V "A")]];
"(Int -> Bool)", "(('A) -> ('B))", mk_s [
"(Int -> Bool)", "('A -> 'B)", mk_s [
[P(V "A","Empty")];
[P(V "A","Int");N("Bool",V "B")]
];
"(Int -> Int) | (Bool -> Bool)", "(('A) -> ('B))", mk_s [
"(Int -> Int) | (Bool -> Bool)", "('A -> 'B)", mk_s [
[P(V "A","Empty")];
(* All these are subsumed as less general then (A <= 0) *)
[P(V "A","Empty");N("Int",V "B")];
......@@ -165,52 +165,52 @@ let norm_tests () = [
[P(V "A","Empty");N("Int | Bool",V "B")]
];
"(('A) -> ('B))", "(Int -> Int) | (Bool -> Bool)", mk_s [
"('A -> 'B)", "(Int -> Int) | (Bool -> Bool)", mk_s [
[P(V "B","Int");N("Int",V "A")];
[P(V "B","Bool");N("Bool",V "A")];
];
(*
"([0--*] & `true)", "(('A) | Int) & ((Any \\ ('A)) | Bool)",
"([0--*] & `true)", "('A | Int) & ((Any \\ 'A) | Bool)",
*)
"(('A) , ('B))","(Int , Bool)", mk_s [
"('A , 'B)","(Int , Bool)", mk_s [
[P(V "A","Empty")];
[P(V "B","Empty")];
[P(V "A","Int");P(V "B","Bool")]
];
"{a=(('A) , ('B))}","{a=(Int , Bool)}", mk_s [
"{a=('A , 'B)}","{a=(Int , Bool)}", mk_s [
[P(V "A","Empty")];
[P(V "B","Empty")];
[P(V "A","Int");P(V "B","Bool")]
];
"{a=(Int , Bool)}","{a=(('A) , ('B))}", mk_s [ [N("Int", V "A");N("Bool", V "B")] ];
"{a=(Int , Bool)}","{a=('A , 'B)}", mk_s [ [N("Int", V "A");N("Bool", V "B")] ];
"(Int , Bool)","(('A) , ('B))", mk_s [ [N("Int", V "A");N("Bool", V "B")] ];
"(Bool , Bool)","(('A) , ('B))", mk_s [ [N("Bool", V "A");N("Bool", V "B")] ];
"(Int , Bool)","('A , 'B)", mk_s [ [N("Int", V "A");N("Bool", V "B")] ];
"(Bool , Bool)","('A , 'B)", mk_s [ [N("Bool", V "A");N("Bool", V "B")] ];
"(('A) | (('B) , ('C)))","(Int , Int)", mk_s [
"('A | ('B , ('C)))","(Int , Int)", mk_s [
[P(V "A","(Int , Int)"); P(V "B","Empty")];
[P(V "A","(Int , Int)"); P(V "C","Empty")];
[P(V "A","(Int , Int)"); P(V "B","Int"); P(V "C","Int")];
];
"(('A) , Int) | (('B) , Bool))","(Int , (Int | Bool))", mk_s [
"('A , Int) | ('B , Bool))","(Int , (Int | Bool))", mk_s [
[P(V "A","Int");P(V "B","Int")]
];
"(('A) -> ('B)) -> [ ('A) ] -> [ ('B) ]", "((Int -> Bool) | ((('A) \\ Int) -> (('B) \\ Int))) -> ('Gamma)", mk_s [
[P(V "A","Empty");N("[('A)] -> [('B)]", V "Gamma")]
"('A -> 'B) -> [ 'A ] -> [ 'B ]", "((Int -> Bool) | (('A \\ Int) -> ('B \\ Int))) -> ('Gamma)", mk_s [
[P(V "A","Empty");N("['A] -> ['B]", V "Gamma")]
];
"Int -> Bool", "('A)", mk_s [[N("Int -> Bool",V "A")]];
"Int -> Bool", "'A", mk_s [[N("Int -> Bool",V "A")]];
"((('A) , Int) & (('B) , Bool))","(Int , (*Int & Bool*) Empty)",Tallying.CS.sat;
"(('A , Int) & ('B , Bool))","(Int , (*Int & Bool*) Empty)",Tallying.CS.sat;
"((('A) , Int) | (('B) , Bool))","(Int , (Int | Bool))", mk_s [
"(('A , Int) | ('B , Bool))","(Int , (Int | Bool))", mk_s [
[P(V "A","Int");P(V "B","Int")]
];
......@@ -237,17 +237,17 @@ let merge_tests () = [
"unsat 1", mk_s [[P(V "A", "Int | Bool");N("Int",V "B");P(V "B", "Empty")]], Tallying.CS.unsat;
"unsat 2", mk_s [[N("Bool",V "B"); N("('B)", V "A"); P(V "A", "Empty")]], Tallying.CS.unsat;
"unsat 2", mk_s [[N("Bool",V "B"); N("'B", V "A"); P(V "A", "Empty")]], Tallying.CS.unsat;
"quad", mk_s [[N("Bool",V "B");N("Int",V "B");N("('B)",V "A"); P(V "A", "Int | Bool")]],
"quad", mk_s [[N("Bool",V "B");N("Int",V "B");N("'B",V "A"); P(V "A", "Int | Bool")]],
mk_s [
[N("('B)", V "A");P(V "A","Int | Bool");N("Int | Bool", V "B"); P(V "B","Int | Bool")]
[N("'B", V "A");P(V "A","Int | Bool");N("Int | Bool", V "B"); P(V "B","Int | Bool")]
];
"add one", mk_s [[N("('B)", V "A");P(V "A","Int | Bool")]],
mk_s [[N("('B)", V "A");P(V "A","Int | Bool");P(V "B","Int | Bool")]];
"add one", mk_s [[N("'B", V "A");P(V "A","Int | Bool")]],
mk_s [[N("'B", V "A");P(V "A","Int | Bool");P(V "B","Int | Bool")]];
"A B", mk_s [[P(V "A", "('B)")]], mk_pp (P(V "A","('B)"));
"A B", mk_s [[P(V "A", "'B")]], mk_pp (P(V "A","'B"));
"", mk_s [[P(V "B", "Empty")]], mk_pp (P(V "B","Empty"));
......@@ -280,48 +280,48 @@ let mk_e ll =
) ll
let tallying_tests = [
[("((Int | Bool) -> Int)", "(('A) -> ('B))")], mk_e [
[("((Int | Bool) -> Int)", "('A -> 'B)")], mk_e [
[(V "A","Empty")];
[(V "A","Int | Bool");(V "B","Int")]
];
[("((Int | Bool) -> Int)", "(('A) -> ('B))"); ("(('A) -> Bool)","(('B) -> ('B))")], mk_e [
[("((Int | Bool) -> Int)", "('A -> 'B)"); ("('A -> Bool)","('B -> 'B)")], mk_e [
[(V "A","Int | Bool");(V "B","Int | Bool")];
[(V "A","Empty");(V "B","Empty")]
];
[("(Int -> Bool)", "(('A) -> ('B))")], mk_e [
[("(Int -> Bool)", "('A -> 'B)")], mk_e [
[(V "A","Empty")];
[(V "A","Int");(V "B","Bool")];
];
[("(Int -> Int) | (Bool -> Bool)", "(('A) -> ('B))")], mk_e [
[("(Int -> Int) | (Bool -> Bool)", "('A -> 'B)")], mk_e [
[(V "A","Empty")];
];
[("((Int,Int) , (Int | Bool))","(('A),Int) | ((('B),Int),Bool)")], mk_e [
[("((Int,Int) , (Int | Bool))","('A,Int) | (('B,Int),Bool)")], mk_e [
[(V "A", "(Int,Int)"); (V "B","Int")]
];
[("((('A) , Int) | (('B) , Bool))","(Int , (Int | Bool))")], mk_e [
[("(('A , Int) | ('B , Bool))","(Int , (Int | Bool))")], mk_e [
[(V "A","Int");(V "B","Int")]
];
[("[] -> []","Int -> ('A)")], [];
[("Bool -> Bool","Int -> ('A)")], [];
[("[] -> []","Int -> 'A")], [];
[("Bool -> Bool","Int -> 'A")], [];
[("((('A) , Int) & (('B) , Bool))","(Int , (Int & Bool))")], [[]];
[("(('A , Int) & ('B , Bool))","(Int , (Int & Bool))")], [[]];
(* map even *)
(* [("(('A) -> ('B)) -> [('A) ] -> [('B) ]","((Int -> Bool) & ((('A) \\ Int) -> (('A) \\ Int)))")], [[]];*)
[("(('A) -> ('A))", "((Int -> Int) & (Bool -> Bool)) -> ('T)")], mk_e [];
(* [("('A -> 'B) -> ['A ] -> ['B ]","((Int -> Bool) & (('A \\ Int) -> ('A \\ Int)))")], [[]];*)
[("('A -> 'A)", "((Int -> Int) & (Bool -> Bool)) -> ('T)")], mk_e [];
(* records *)
[("{a=Int}","Any")], [[]];
[("{a=('A)}","Any")], [[]];
[("{a='A}","Any")], [[]];
[("{a=Int}","{a=(Int|Bool)}")], [[]];
(*
[("{a=Bool -> Bool}","{b=Int -> ('A)}")], [[]];
[("{a=(Int -> Int) | (Bool -> Bool)}","{b=(('A) -> ('B))}")], [[]];
[("{a=Int} -> Int", "{a=('A)} -> ('A)")], [[]];
[("{a=Bool -> Bool}","{b=Int -> 'A}")], [[]];
[("{a=(Int -> Int) | (Bool -> Bool)}","{b=('A -> 'B)}")], [[]];
[("{a=Int} -> Int", "{a='A} -> 'A")], [[]];
*)
]
......@@ -353,100 +353,100 @@ let test_tallying =
let apply_raw_tests = [
"iter hd",
"(('A) -> []) -> [ ('A)* ] -> []","[ ('A0)* ] -> ('A0)";
"('A -> []) -> [ 'A* ] -> []","[ ('A0)* ] -> ('A0)";
"iteri assoc",
"(Int -> ('A) -> []) -> [ ('A)* ] -> []","('A1) -> [ (('A1) , ('B1))* ] -> ('B1)";
"(Int -> 'A -> []) -> [ 'A* ] -> []","('A1) -> [ (('A1) , ('B1))* ] -> ('B1)";
"map length",
"(('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","[ ('A3)* ] -> Int";
"('A -> 'B) -> [ 'A* ] -> [ 'B* ]","[ ('A3)* ] -> Int";
"map length & hd",
"(('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","([ ('A3)* ] -> Int) & ([ ('A4)* ] -> ('A4))";
"('A -> 'B) -> [ 'A* ] -> [ 'B* ]","([ ('A3)* ] -> Int) & ([ ('A4)* ] -> ('A4))";
"mapi mem",
"(Int -> ('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","('A45) -> [ ('A45)* ] -> Bool";
"(Int -> 'A -> 'B) -> [ 'A* ] -> [ 'B* ]","('A45) -> [ ('A45)* ] -> Bool";
"mapi mem & memq",
"(Int -> ('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","(('A45) -> [ ('A45)* ] -> Bool) & (('A46) -> [ ('A46)* ] -> Bool)";
"(Int -> 'A -> 'B) -> [ 'A* ] -> [ 'B* ]","(('A45) -> [ ('A45)* ] -> Bool) & (('A46) -> [ ('A46)* ] -> Bool)";
"rev_map length",
"(('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","[ ('A53)* ] -> Int";
"('A -> 'B) -> [ 'A* ] -> [ 'B* ]","[ ('A53)* ] -> Int";
"rev_map length & hd",
"(('A) -> ('B)) -> [ ('A)* ] -> [ ('B)* ]","([ ('A53)* ] -> Int) & ([ ('A54)* ] -> ('A54))";
"('A -> 'B) -> [ 'A* ] -> [ 'B* ]","([ ('A53)* ] -> Int) & ([ ('A54)* ] -> ('A54))";
"fold_left append",
"(('A) -> ('B) -> ('A)) -> ('A) -> [ ('B)* ] -> ('A)","[ ('A95)* ] -> [ ('A95)* ] -> [ ('A95)* ]";
"('A -> 'B -> 'A) -> 'A -> [ 'B* ] -> 'A","[ ('A95)* ] -> [ ('A95)* ] -> [ ('A95)* ]";
"fold_right hd",
"(('A) -> ('B) -> ('B)) -> [ ('A)* ] -> ('B) -> ('B)","[ ('A103)* ] -> ('A103)";
"('A -> 'B -> 'B) -> [ 'A* ] -> 'B -> 'B","[ ('A103)* ] -> ('A103)";
"iter2 hd",
"(('A) -> ('B) -> []) -> [ ('A)* ] -> [ ('B)* ] -> []","[ ('A117)* ] -> ('A117)";
"('A -> 'B -> []) -> [ 'A* ] -> [ 'B* ] -> []","[ ('A117)* ] -> ('A117)";
"map2 hd",
"(('A) -> ('B) -> ('C)) -> [ ('A)* ] -> [ ('B)* ] -> [ ('C)* ]","[ ('A124)* ] -> ('A124)";
"('A -> 'B -> ('C)) -> [ 'A* ] -> [ 'B* ] -> [ ('C)* ]","[ ('A124)* ] -> ('A124)";
"rev_map2 hd",
"(('A) -> ('B) -> ('C)) -> [ ('A)* ] -> [ ('B)* ] -> [ ('C)* ]","[ ('A160)* ] -> ('A160)";
"('A -> 'B -> ('C)) -> [ 'A* ] -> [ 'B* ] -> [ ('C)* ]","[ ('A160)* ] -> ('A160)";
"fold_left2 assoc",
"(('A) -> ('B) -> ('C) -> ('A)) -> ('A) -> [ ('B)* ] -> [ ('C)* ] -> ('A)","('A196) -> [ (('A196) , ('B196))* ] -> ('B196)";
"('A -> 'B -> ('C) -> 'A) -> 'A -> [ 'B* ] -> [ ('C)* ] -> 'A","('A196) -> [ (('A196) , ('B196))* ] -> ('B196)";
"for_all hd",
"(('A) -> Bool) -> [ ('A)* ] -> Bool","[ ('A198)* ] -> ('A198)";
"('A -> Bool) -> [ 'A* ] -> Bool","[ ('A198)* ] -> ('A198)";
"exists hd",
"(('A) -> Bool) -> [ ('A)* ] -> Bool","[ ('A199)* ] -> ('A199)";
"('A -> Bool) -> [ 'A* ] -> Bool","[ ('A199)* ] -> ('A199)";
"for_all2 hd",
"(('A) -> ('B) -> Bool) -> [ ('A)* ] -> [ ('B)* ] -> Bool","[ ('A200)* ] -> ('A200)";
"('A -> 'B -> Bool) -> [ 'A* ] -> [ 'B* ] -> Bool","[ ('A200)* ] -> ('A200)";
"exists2 hd",
"(('A) -> ('B) -> Bool) -> [ ('A)* ] -> [ ('B)* ] -> Bool","[ ('A211)* ] -> ('A211)";
"('A -> 'B -> Bool) -> [ 'A* ] -> [ 'B* ] -> Bool","[ ('A211)* ] -> ('A211)";
"mem length",
"('A) -> [ ('A)* ] -> Bool","[ ('A222)* ] -> Int";
"'A -> [ 'A* ] -> Bool","[ ('A222)* ] -> Int";
"memq length",
"('A) -> [ ('A)* ] -> Bool","[ ('A264)* ] -> Int";
"'A -> [ 'A* ] -> Bool","[ ('A264)* ] -> Int";
"find hd",
"(('A) -> Bool) -> [ ('A)* ] -> ('A)","[ ('A306)* ] -> ('A306)";
"('A -> Bool) -> [ 'A* ] -> 'A","[ ('A306)* ] -> ('A306)";
"filter hd",
"(('A) -> Bool) -> [ ('A)* ] -> [ ('A)* ]","[ ('A307)* ] -> ('A307)";
"('A -> Bool) -> [ 'A* ] -> [ 'A* ]","[ ('A307)* ] -> ('A307)";
"find_all hd",
"(('A) -> Bool) -> [ ('A)* ] -> [ ('A)* ]","[ ('A308)* ] -> ('A308)";
"('A -> Bool) -> [ 'A* ] -> [ 'A* ]","[ ('A308)* ] -> ('A308)";
"partition hd",
"(('A) -> Bool) -> [ ('A)* ] ->( [ ('A)* ] , [ ('A)* ])","[ ('A309)* ] -> ('A309)";
"('A -> Bool) -> [ 'A* ] ->( [ 'A* ] , [ 'A* ])","[ ('A309)* ] -> ('A309)";
"assoc length",
"('A) -> [ (('A) , ('B))* ] -> ('B)","[ ('A310)* ] -> Int";
"'A -> [ ('A , 'B)* ] -> 'B","[ ('A310)* ] -> Int";
"assoc length & hd",
"('A) -> [ (('A) , ('B))* ] -> ('B)","([ ('A310)* ] -> Int) & ([ ('A311)* ] -> ('A311))";
"'A -> [ ('A , 'B)* ] -> 'B","([ ('A310)* ] -> Int) & ([ ('A311)* ] -> ('A311))";
"mem_assoc length",
"('A) -> [ (('A) , ('B))* ] -> Bool","[ ('A394)* ] -> Int";
"'A -> [ ('A , 'B)* ] -> Bool","[ ('A394)* ] -> Int";
"mem_assoc length & hd",
"('A) -> [ (('A) , ('B))* ] -> Bool","([ ('A394)* ] -> Int) & ([ ('A395)* ] -> ('A395))";
"'A -> [ ('A , 'B)* ] -> Bool","([ ('A394)* ] -> Int) & ([ ('A395)* ] -> ('A395))";
"mem_assq length",
"('A) -> [ (('A) , ('B))* ] -> Bool","[ ('A436)* ] -> Int";
"'A -> [ ('A , 'B)* ] -> Bool","[ ('A436)* ] -> Int";
"mem_assq length & hd",
"('A) -> [ (('A) , ('B))* ] -> Bool","([ ('A436)* ] -> Int) & ([ ('A437)* ] -> ('A437))";
"'A -> [ ('A , 'B)* ] -> Bool","([ ('A436)* ] -> Int) & ([ ('A437)* ] -> ('A437))";
"remove_assoc length",
"('A) -> [ (('A) , ('B))* ] -> [ (('A) , ('B))* ]","[ ('A478)* ] -> Int";
"'A -> [ ('A , 'B)* ] -> [ ('A , 'B)* ]","[ ('A478)* ] -> Int";
"remove_assoc length & hd",
"('A) -> [ (('A) , ('B))* ] -> [ (('A) , ('B))* ]","([ ('A478)* ] -> Int) & ([ ('A479)* ] -> ('A479))";
"'A -> [ ('A , 'B)* ] -> [ ('A , 'B)* ]","([ ('A478)* ] -> Int) & ([ ('A479)* ] -> ('A479))";
]
let test_apply =
......
......@@ -34,11 +34,11 @@ let iteri (f : (Int -> 'a -> []))(l : [('a)*]) : [] =
| [el; rest] -> f pos el; aux f rest (pos + 1)
in
aux f l 0
(*
let mapf (f : 'a -> 'b)(l : [('a)*]) : [('b)*] =
let aux (f : 'a -> 'b)(l : [('a)*])(acc : [('b)*]) : [('b)*] = match l with
| [] -> acc
| [el; rest] -> aux f rest (acc @ [(f el)]) in
aux f l []
*)
(* List scanning *)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment