Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
5c21ad34
Commit
5c21ad34
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2002-10-21 19:11:57 by cvscast] Empty log message
Original author: cvscast Date: 2002-10-21 19:13:15+00:00
parent
960d71e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/addrbook.cd
View file @
5c21ad34
...
...
@@ -4,9 +4,7 @@ type Name = <name>[String];;
type Addr = <addr>[String];;
type Tel = <tel>[String];;
fun (Int -> Int) 0
-> 1;;
(*
<addrbook>[
<name>["Haruo Hosoya"]
<addr>["Tokyo"]
...
...
@@ -43,7 +41,7 @@ fun (Int -> Int) 0
<name>["Peter Buneman"]
<addr>["Scotland"]
];;
*)
(*
...
...
@@ -58,6 +56,7 @@ fun mkTelList ([ (Name Addr Tel?)* ] -> [ (Name Tel)* ])
fun mkTelList (Addrbook -> [ (Name Tel)* ])
<_>[ ( ( (x::Name) Addr (x::Tel) ) | _ )* ] -> x
;;
*)
fun (Int -> Addrbook) x ->
<addrbook>[
...
...
@@ -70,7 +69,22 @@ fun (Int -> Addrbook) x ->
<addr>["Scotland"]
]
;;
(*
fun (Int -> Addrbook) x ->
<addrbook>[
<name>["Haruo Hosoya"]
<addr>["Tokyo"]
<name>["Benjamin Pierce"]
<addr>["Philadelphia"]
<tel>["123-456-789"]
<name>["Peter Buneman"]
<addr>["Scotland"]
]
;;
*)
(*
match <addrbook>[
<name>["Haruo Hosoya"]
<addr>["Tokyo"]
...
...
typing/typer.ml
View file @
5c21ad34
...
...
@@ -424,6 +424,7 @@ and type_check' loc env e constr precise = match e with
|
Match
(
e
,
b
)
->
let
t
=
type_check
env
e
b
.
br_accept
true
in
type_check_branches
loc
env
t
b
constr
precise
|
Pair
(
e1
,
e2
)
->
let
rects
=
Types
.
Product
.
get
constr
in
if
Types
.
Product
.
is_empty
rects
then
...
...
@@ -438,6 +439,7 @@ and type_check' loc env e constr precise = match e with
Types
.
times
(
Types
.
cons
t1
)
(
Types
.
cons
t2
)
else
constr
|
RecordLitt
r
->
let
rconstr
=
Types
.
Record
.
get
constr
in
if
Types
.
Record
.
is_empty
rconstr
then
...
...
@@ -498,6 +500,24 @@ and compute_type' loc env = function
|
Map
(
e
,
b
)
->
let
t
=
compute_type
env
e
in
Sequence
.
map
(
fun
t
->
type_check_branches
loc
env
t
b
Types
.
any
true
)
t
(* We keep these cases here to allow comparison and benchmarking ...
Just comment the corresponding cases in type_check' to
activate these ones.
*)
|
Pair
(
e1
,
e2
)
->
let
t1
=
compute_type
env
e1
and
t2
=
compute_type
env
e2
in
Types
.
times
(
Types
.
cons
t1
)
(
Types
.
cons
t2
)
|
RecordLitt
r
->
List
.
fold_left
(
fun
accu
(
l
,
e
)
->
let
t
=
compute_type
env
e
in
let
t
=
Types
.
record
l
false
(
Types
.
cons
t
)
in
Types
.
cap
accu
t
)
Types
.
Record
.
any
r
|
_
->
assert
false
and
type_check_branches
loc
env
targ
brs
constr
precise
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment