Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple parameters type

Tags:

ocaml

I'm trying to write something like this:

type 'a 'b xxx = {aaa: 'a: bbb: 'b: ccc: int};;

It does not compile. Is it just syntax error, or they don't allow multiple paramters on type ? Then why ?

like image 542
romerun Avatar asked May 25 '10 03:05

romerun


2 Answers

In ML, multiple type parameters are written between parentheses and separated by commas, like this:

type ('a,'b) xxx = {aaa: 'a; bbb: 'b; ccc: int; }
like image 105
nlucaroni Avatar answered Sep 20 '22 04:09

nlucaroni


Actually you can write like this, in revised syntax :

        Objective Caml version 3.11.2

# #load "dynlink.cma";;
# #load "camlp4r.cma";;
    Camlp4 Parsing version 3.11.2

# type xxx 'a 'b = { aaa : 'a; bbb: 'b; ccc: int};
type xxx 'a 'b = { aaa : 'a; bbb : 'b; ccc : int }
like image 37
ygrek Avatar answered Sep 21 '22 04:09

ygrek