Commit efe6fa1e authored by Julien Lopez's avatar Julien Lopez

Remove old syntax `$IDENT for type variables.

parent 92cc25ff
This diff is collapsed.
......@@ -406,7 +406,6 @@ EXTEND Gram
tag_type: [
[ "_" -> mk _loc (Internal (Types.atom Atoms.any))
| "$"; a = ident_or_keyword -> mk _loc (TVar a)
| a = ident_or_keyword -> mk _loc (Cst (Atom (ident a)))
| t = ANY_IN_NS -> mk _loc (NsT (ident t))
]
......
......@@ -28,14 +28,14 @@ let tests_poly_abstr = [
"fun f x : Int : Int -> 2";
"Test CDuce.lambda.poly.identity failed",
"Abstraction(Dummy,,,,Sel(,[([ Char* ] | Int -> [ Char* ] | Int)],Comp({},{{ `$A =
Int },{ `$A = [ Char* ]
"Abstraction(Dummy,,,,Sel(,[([ Char* ] | Int -> [ Char* ] | Int)],Comp({},{{ 'A =
Int },{ 'A = [ Char* ]
}})))",
"(fun f x : 'A : 'A -> x) [{A/Int},{A/String}]";
"Test CDuce.runtime.poly.tail failed",
"Abstraction(Dummy,,,,Sel(,[([ (`$A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow)* ] -> [ (`$A & Int |
"Abstraction(Dummy,,,,Sel(,[([ ('A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow)* ] -> [ ('A & Int |
Char |
Atom |
(Any,Any) |
......@@ -43,19 +43,19 @@ Int },{ `$A = [ Char* ]
Arrow)* ])],{}))",
"fun tail x : ['A] : ['A] -> match x : ['A] with | (el : 'A) :: (rest : ['A]) -> rest";
"Test CDuce.runtime.poly.pair failed", "Abstraction(Dummy,,,,Sel(,[((`$A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow,`$B & Int | Char |
"Test CDuce.runtime.poly.pair failed", "Abstraction(Dummy,,,,Sel(,[(('A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow,'B & Int | Char |
Atom | (Any,Any) | <(Any) (Any)>Any | Arrow) ->
`$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | Arrow)],{}))",
'A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | Arrow)],{}))",
"fun pair x : ('A * 'B) : 'A -> match x : ('A * 'B) with | (z : 'A, y : 'B) -> z";
"Test CDuce.runtime.poly.match_abstr failed", "Apply(Match(Abstraction(Dummy,,,,Sel(,[(`$A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow -> `$A & Int |
"Test CDuce.runtime.poly.match_abstr failed", "Apply(Match(Abstraction(Dummy,,,,Sel(,[('A & Int | Char | Atom | (Any,Any) |
<(Any) (Any)>Any | Arrow -> 'A & Int |
Char |
Atom |
(Any,Any) |
<(Any) (Any)>Any |
Arrow)],{})), {accept_chars=false; brs_disp=<disp>; brs_rhs=[| (2, TVar(Local(0),Comp({},{ { `$A =
Arrow)],{})), {accept_chars=false; brs_disp=<disp>; brs_rhs=[| (2, TVar(Local(0),Comp({},{ { 'A =
Int
} }))) |]; brs_stack_pos=0}),Const(3))",
"(match (fun f x : 'A : 'A -> x) : ('A -> 'A) with | y : ('A -> 'A) -> y[{A/Int}]).3";
......@@ -73,7 +73,7 @@ let tests_poly_abstr = [
"Test CDuce.lambda.identity_applied failed",
"Apply(PolyAbstraction([Dummy,Dummy],,{accept_chars=true; brs_disp=<disp>; brs_rhs=[| (1, Var(Local(0))) |]; brs_stack_pos=0},,Sel(Env(1),[(
`$A -> `$A)],{{`$A = Int
'A -> 'A)],{{'A = Int
}})),Const(2))",
"(fun f x : 'A : 'A -> x)[{A/Int}].2";
];;
......@@ -213,14 +213,14 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| x : (!(Int|Bool)) -> x).[2; 3]");
assert_equal ~msg:"Test CDuce.runtime.misc.map failed"
~printer:(fun x -> x)
"Abstraction([(`$A -> `$B,[ `$A* ] -> [ `$B* ])],Id)"
"Abstraction([('A -> 'B,[ 'A* ] -> [ 'B* ])],Id)"
(run_test_eval "fun map f : ('A -> 'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: [] -> f.el
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))");
assert_equal ~msg:"Test CDuce.runtime.misc.map_even failed"
~printer:(fun x -> x)
"Abstraction([([ `$A* ],[ `$B* ])],Id)"
"Abstraction([([ 'A* ],[ 'B* ])],Id)"
(run_test_eval "(fun map f : ('A->'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))
......@@ -254,7 +254,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
assert_equal ~msg:"Test CDuce.runtime.misc.map_even_hard failed"
~printer:(fun x -> x)
"(Atom(true),(\"hey\",((3,(5,Atom(nil),Mono),Mono),(Atom(true),(Abstraction([(
`$C,`$C)],Id),(Atom(false),Atom(nil),Mono),Mono),Mono),Mono),Mono),Mono)"
'C,'C)],Id),(Atom(false),Atom(nil),Mono),Mono),Mono),Mono),Mono),Mono)"
(run_test_eval "(fun map f : ('A->'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))
......@@ -456,12 +456,12 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
"poly" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.poly.identity_pure failed"
~printer:(fun x -> x)
"Abstraction([(`$A,`$A)],Id)"
"Abstraction([('A,'A)],Id)"
(run_test_eval "fun f x : 'A : 'A -> x");
assert_equal ~msg:"Test CDuce.runtime.poly.identity failed"
~printer:(fun x -> x)
"Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],{{`$A = Int},{`$A = [ Char* ]
"Abstraction([('A,'A)],Sel(1,[('A -> 'A)],{{'A = Int},{'A = [ Char* ]
}}))"
(run_test_eval "(fun f x : 'A : 'A -> x)[{A/Int},{A/String}]");
......@@ -475,7 +475,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
assert_equal ~msg:"Test CDuce.runtime.poly.tail failed"
~printer:(fun x -> x)
"Abstraction([([ `$A* ],[ `$A* ])],Id)"
"Abstraction([([ 'A* ],[ 'A* ])],Id)"
(run_test_eval "fun tail x : ['A] : ['A] -> match x : ['A] with
| (_ : 'A) :: (rest : ['A]) -> rest");
......@@ -485,31 +485,30 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| (_ : 'A) :: (rest : ['A]) -> rest).[3; 7; 8; 5]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp failed"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],{{`$A = Int
~printer:(fun x -> x) "Abstraction([('A,'A)],Sel(1,[('A -> 'A)],{{'A = Int
}}))"
(run_test_eval "(((fun f x : 'A : 'A -> x)[{A/Int}])[{A/String}])[{A/Bool}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.2 failed"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp({{`$A = `$B
}},{{`$B = `$A}}),{{`$A = `$B
~printer:(fun x -> x) "Abstraction([('A,'A)],Sel(1,[('A -> 'A)],Comp(Comp({{'A = 'B}},{{'B =
'A}}),{{'A = 'B
}})))"
(run_test_eval "(((fun f x : 'A : 'A -> x)[{A/'B}])[{B/'A}])[{A/'B}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.3 failed"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp(Comp({{`$B = `$A
}},{{`$A = `$B}}),{{`$B = `$A}}),{{`$A = `$B
~printer:(fun x -> x) "Abstraction([('A,'A)],Sel(1,[('A -> 'A)],Comp(Comp(Comp({{'B = 'A}},{{'A =
'B}}),{{'B = 'A}}),{{'A = 'B
}})))"
(run_test_eval "((((fun f x : 'A : 'A -> x)[{A/'B}])[{B/'A}])[{A/'B}])[{B/'A}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.4 failed"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp({{`$B = Int}},{{`$A =
`$B
~printer:(fun x -> x) "Abstraction([('A,'A)],Sel(1,[('A -> 'A)],Comp({{'B = Int}},{{'A = 'B
}})))"
(run_test_eval "(((((fun f x : 'A : 'A -> x)[{A/'B}])[{A/Int}])[{B/Int}])[{B/Int}])[{B/'A}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.5 failed"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp({{`$D = `$C
},{`$C = `$B}},{{`$B = `$C}}),{{`$A = `$B},{`$C = `$D
~printer:(fun x -> x) "Abstraction([('A,'A)],Sel(1,[('A -> 'A)],Comp(Comp({{'D = 'C},{'C = 'B
}},{{'B = 'C}}),{{'A = 'B},{'C = 'D
}})))"
(run_test_eval "((((fun f x : 'A : 'A -> x)[{A/'B},{C/'D}])[{B/'C}])[{B/'D}])[{D/'C},{C/'B}]");
......
......@@ -20,28 +20,28 @@ let tests_typer_list = [
"Test CDuce.typed.fun.identity",
"fun f x : 'A : 'A -> x",
"fun f (`$A -> `$A) x -> x";
"fun f ('A -> 'A) x -> x";
"Test CDuce.typed.fun.identity.int",
"fun f x : 'A : 'A -> 2",
"fun f (`$A -> `$A) x -> x";
"fun f ('A -> 'A) x -> x";
"Test CDuce.typed.fun.match",
"fun f x : ('A | Int) : ('A | Int) -> x",
"fun f (`$A -> `$A) x & Int -> x | x -> x";
"fun f ('A -> 'A) x & Int -> x | x -> x";
"Test CDuce.typed.fun.partial 1",
"fun f x : 'A : 'A -> 2",
"fun f ( `$A -> `$A -> `$A) x -> fun g -> g x";
"fun f ( 'A -> 'A -> 'A) x -> fun g -> g x";
"Test CDuce.typed.fun.partial 2",
"fun f x : 'A : 'A -> 2",
"fun f ( g : `$A -> `$B ) ( x : `$A) : `$B = g x";
"fun f ( g : 'A -> 'B ) ( x : 'A) : 'B = g x";
*)
"Test CDuce.typed.fun.partial 2",
"fun f x : 'A : 'A -> 2",
"let id ( y : `$A ) : `$B = y in id";
"let id ( y : 'A ) : 'B = y in id";
]
......
......@@ -28,11 +28,11 @@ let tests_poly_abstr = [
"(fun (x : 'A) : 'A = x) `a";
"Test CDuce.lambda.partial",
"Abstraction([(`$A,Int -> Int)],Id)",
"Abstraction([('A,Int -> Int)],Id)",
"fun ('A -> (Int -> Int)) | _ -> (fun ('B -> 'B) y -> y)";
"Test CDuce.lambda.appl_partial",
"Abstraction([(`$B,`$B)],Id)",
"Abstraction([('B,'B)],Id)",
"(fun ('A -> (Int -> Int)) | _ -> (fun ('B -> 'B) y -> y)) 3";
];;
......
This diff is collapsed.
......@@ -15,9 +15,9 @@ function cduce_type
t2=$(echo "$t1" | sed -e "s/\(\[[^]]*\]\) list/[ \1* ]/g")
t3=$(echo "$t2" | sed -e "s/\(\[[^]]*\]\) list/[ \1* ]/g")
t4=$(echo "$t3" | sed -e "s/\(\[[^]]*\]\) list/[ \1* ]/g")
t5=$(echo "$t4" | sed -e "s/'\([_a-z]*\)/\`$\U\1/g" )
t5=$(echo "$t4" | sed -e "s/'\([_a-z]*\)/\'\U\1/g" )
t6=$(echo "$t5" | sed -e "s/\(int\|bool\)/\u\1/g" | sed -e "s/unit/[]/g" | sed -e 's/_//g')
echo "type t = $t6" | sed -e 's/\(`$[A-Z]*\)/Any/g' > test.cd
echo "type t = $t6" | sed -e "s/\('[A-Z]*\)/Any/g" > test.cd
cduce -c test.cd >/dev/null 2>&1
if [ "$?" = "0" ]; then
echo $t6
......@@ -67,14 +67,14 @@ for i in `seq 0 "$last_type"`; do
ACCNAME=${FUNNAME[$first]}
ACCTYPE=${FUNTYPE[$first]}
echo "(* ${ARGNAME} ${ACCNAME} *)"
FTYPE="$(echo ${ACCTYPE} | sed -e 's:\(`$[A-Z]*\):\1'$num':g')"
FTYPE="$(echo ${ACCTYPE} | sed -e "s:\(\'[A-Z]*\):\1\'$num\':g")"
print_line "$ARG" "$FTYPE"
num=$(($num + 1))
ACCTYPE="($FTYPE)"
for j in $others; do
ACCNAME="$ACCNAME & ${FUNNAME[$j]}"
echo "(* ${ARGNAME} ${ACCNAME} *)"
FTYPE="$(echo ${FUNTYPE[$j]} | sed -e 's:\(`$[A-Z]*\):\1'$num':g')"
FTYPE="$(echo ${FUNTYPE[$j]} | sed -e "s:\(\'[A-Z]*\):\1\'$num\':g")"
ACCTYPE="$ACCTYPE & (${FTYPE})"
print_line "$ARG" "${ACCTYPE}"
num=$(($num + 1))
......
......@@ -9,14 +9,14 @@ def f (a,a1,p1) :
tmplist = [["" for i in xrange(6)] for i in xrange(arity)]
for i in range(arity) :
a = [ "`$A%d" % j for j in range(i+1)]
a = [ "'A%d" % j for j in range(i+1)]
f1 = " -> ".join(a)
p1 = " , ".join(a)
tn1,tn2,tn3 = f (f1, "`$A0", p1)
a = [ "(`$A%d%d -> `$A%d)" % (j,j,j) for j in range(i+1)]
tn1,tn2,tn3 = f (f1, "'A0", p1)
a = [ "('A%d%d -> 'A%d)" % (j,j,j) for j in range(i+1)]
f1 = " -> ".join(a)
p1 = " , ".join(a)
sn1,sn2,sn3 = f (f1, "`$A1", p1)
sn1,sn2,sn3 = f (f1, "'A1", p1)
tmplist[i] = [tn1,tn2,tn3,sn1,sn2,sn3]
slist = []
......
......@@ -9,12 +9,12 @@ do
echo -n '"'
for j in `seq 1 $i`
do
echo -n '`$A'${PREF}${j}' -> '
echo -n ''A'${PREF}${j}' -> '
done
echo 'Int", ['
for j in `seq 1 $i`
do
echo '"`$B'${PREF}${j}'";'
echo '"'B'${PREF}${j}'";'
#echo '"Int";'
done
echo "];"
......@@ -26,30 +26,30 @@ echo "];;"
echo "let funs_hh = ["
for i in `seq 1 15`
do
echo -n '"( `$A'${PREF}1' -> `$B'${PREF}1' ) '
echo -n '"( 'A'${PREF}1' -> 'B'${PREF}1' ) '
for j in `seq 2 $i`
do
echo -n '-> ( `$A'${PREF}${j}' -> `$B'${PREF}${j}' ) '
echo -n '-> ( 'A'${PREF}${j}' -> 'B'${PREF}${j}' ) '
done
echo -n '-> `$A'${PREF}1' '
echo -n '-> 'A'${PREF}1' '
for j in `seq 2 $i`
do
echo -n '-> `$A'${PREF}${j}' '
echo -n '-> 'A'${PREF}${j}' '
done
echo -n ' -> ('
echo -n '`$B'${PREF}1
echo -n ''B'${PREF}1
for j in `seq 2 $i`
do
echo -n ', `$B'${PREF}${j}
echo -n ', 'B'${PREF}${j}
done
echo ')", ['
for j in `seq 1 $i`
do
echo '" (`$C'${PREF}${j}' -> `$D'${PREF}${j}' ) ";' # & (`$E'${PREF}${j}' -> `$F'${PREF}${j}') ";'
echo '" ('C'${PREF}${j}' -> 'D'${PREF}${j}' ) ";' # & ('E'${PREF}${j}' -> 'F'${PREF}${j}') ";'
done
for j in `seq 1 $i`
do
echo '" (`$C'${PREF}${j}' )";' # |`$E'${PREF}${j}') ";'
echo '" ('C'${PREF}${j}' )";' # |'E'${PREF}${j}') ";'
done
echo "];"
PREF=$(($PREF + 1 ))
......
......@@ -19,36 +19,36 @@ let print_tests = [
"(Int,Int)";
"Int -> Int";
"Bool -> Bool";
"Int -> `$A";
"Int -> 'A";
"[] -> []";
"Int -> `$A";
"(`$A -> Bool)";
"(`$B -> `$B)";
"Int -> 'A";
"('A -> Bool)";
"('B -> 'B)";
"(Int -> Bool)";
"(Int -> Int) | (Bool -> Bool)";
"(Int -> Int) | (Bool -> Bool)";
"([0--*] & `true)";
"(`$A | Int) & ((Any \\ `$A) | Bool)";
"(`$A | (`$B , `$C))";
"('A | Int) & ((Any \\ 'A) | Bool)";
"('A | ('B , 'C))";
"(Int , Int)";
"(`$A -> `$B) -> [ `$A ] -> [ `$B ]";
"((Int -> Bool) | ((`$A \\ Int) -> (`$B \\ Int))) -> `$Gamma";
"((`$A , Int) & (`$B , Bool))";
"('A -> 'B) -> [ 'A ] -> [ 'B ]";
"((Int -> Bool) | (('A \\ Int) -> ('B \\ Int))) -> 'Gamma";
"(('A , Int) & ('B , Bool))";
"(Int , (*Int & Bool*) Empty)";
"((`$A , Int) | (`$B , Bool))";
"(('A , Int) | ('B , Bool))";
"(Int , (Int | Bool))";
"((Int | Bool) -> Int)";
"((Int | Bool) -> Int)";
"(Int -> Int) | (Bool -> Bool)";
"((Int,Int) , (Int | Bool))";
"(`$A,Int) | ((`$B,Int),Bool)";
"((`$A , Int) | (`$B , Bool))";
"('A,Int) | (('B,Int),Bool)";
"(('A , Int) | ('B , Bool))";
"(Int , (Int | Bool))";
"((`$A , Int) & (`$B , Bool))";
"(('A , Int) & ('B , Bool))";
"(Int , (Int & Bool))";
"(`$A -> `$B) -> [`$A ] -> [`$B ]";
"((Int -> Bool) & ((`$A \\ Int) -> (`$A \\ Int)))";
"((Int -> Int) & (Bool -> Bool)) -> `$T";
"('A -> 'B) -> ['A ] -> ['B ]";
"((Int -> Bool) & (('A \\ Int) -> ('A \\ Int)))";
"((Int -> Int) & (Bool -> Bool)) -> 'T";
]
let test_print =
......
This diff is collapsed.
This diff is collapsed.
type T = <a>[`$A*];;
type T = <a>[('A)*];;
let fun f ( <a>l : T ) : Int = aux l;;
let fun aux ([`$A*] -> Int)
let fun aux ([('A)*] -> Int)
| [] -> 0
| (x,r) -> (aux r);;
......
......@@ -16,7 +16,7 @@ type var = [ `Var of t ]
type 'a pairvar = [ `Atm of 'a | var ]
let dump ppf (`Var x) = Format.fprintf ppf "%a" dump x
let print ppf (`Var x) = Format.fprintf ppf "`$%s" x.id
let print ppf (`Var x) = Format.fprintf ppf "'%s" x.id
let compare (`Var x) (`Var y) = compare x y
let equal v1 v2 = (compare v1 v2) = 0
......
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