Version française
Home     About     Download     Resources     Contact us    
Browse thread
Upgrading sexplib-2.7.0 to camlp4 3.10
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: Upgrading sexplib-2.7.0 to camlp4 3.10
On 4/30/07, Joel Reymont <joelr1@gmail.com> wrote:
> What does this match? I assume that $list...$ is a list but the dot
> in the middle throws me off.
>
>      | <:ctyp< ! $list:parms$ . $tp$ >> -> poly _loc parms tp
>
> Is this a good translation?
>
>      | <:ctyp< ! $id:id$ >> ->
>        (match id with
>           | <:ident< $list:params$ . $tp$ >> ->
>             poly _loc parms tp
>           | _ -> failwith "fold_tp: unknown type")

No, the dot here is not the same it's part of the syntax for rank-2
polymorphism.

t ::= ... | ! 'a ... 'z . t

Having a function to unfold 'a ... 'z to a list.

let unfold_params x =
  let rec loop x acc =
    match x with
    | <:ctyp<>> -> acc
    | <:ctyp< $x$ $y$ >> -> loop x (loop y acc)
    | x -> x :: acc
  in loop x [];;

...
| <:ctyp< ! $params$ . $t$ >> ->
   poly _loc (unfold_params params) t
...

-- 
Nicolas Pouillard