Version française
Home     About     Download     Resources     Contact us    
Browse thread
GenerateFold
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Joel Reymont <joelr1@g...>
Subject: Re: GenerateFold
I thought I would try to reproduce the issue but I can't.

I get a different issue instead. It doesn't like the following line

       | `FunArgDecl _ -> {< found = true >}

or `FunargDecl to be precise.

Also, what does {< found = true >} mean?

	Thanks, Joel

---

ocamlbuild c.byte
+ /usr/local/bin/ocamlc.opt -c -I +camlp4 -pp 'camlp4of -I src - 
filter map -filter fold -filter trash ' -o b.cmo b.ml
File "b.ml", line 11, characters 8-21:
This pattern matches values of type [> `FunArgDecl of 'a ]
but is here used to match values of type
   < array : 'c. ('b -> 'c -> 'b) -> 'c array -> 'b; bool : bool -> 'b;
     expr : A.expr -> 'b; float : float -> 'b; found : bool; id :  
A.id -> 'b;
     input_decl : A.input_decl -> 'b; int : int -> 'b;
     list : 'd. ('b -> 'd -> 'b) -> 'd list -> 'b;
     option : 'e. ('b -> 'e -> 'b) -> 'e option -> 'b;
     program : A.program -> 'b; ref : 'f. ('b -> 'f -> 'b) -> 'f ref - 
 > 'b;
     statement : A.statement -> 'b; string : A.id -> 'b;
     subscript : A.subscript -> 'b; ty : A.ty -> 'b >
   as 'b

cat _tags
"b.ml": use_camlp4, pp(camlp4of -I src -filter map -filter fold - 
filter trash )

cat a.ml
type id = string

and program = statement list

and ty =
     [
     | `TyAny
     ]

and statement =
     [
     | `Skip
     | `InputDecls of input_decl list
     ]

and subscript = expr list

and input_decl =
     [
     | `InputDecl of id * ty * expr
     | `FunArgDecl of id * ty * subscript
     ]

and expr =
     [
     | `Int of int
     | `Float of float
     | `Str of string
     ]

cat b.ml
open A

class fold = Camlp4Filters.GenerateFold.generated;;

let is_fun_arg = object (self)
   inherit fold as super
   val found = false
   method found = found
   method input_decl x =
     match super#input_decl x with
       | `FunArgDecl _ -> {< found = true >}
       | _             -> self
end

let is_fun x = (is_fun_arg#statement x)#found;;

module Camlp4Trash = struct
   INCLUDE "a.ml";;
end;;

cat c.ml
open A
open B


--
http://topdog.cc      - EasyLanguage to C# translator
http://wagerlabs.com  - Blog