caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* GenerateFold
@ 2007-05-31 12:18 Joel Reymont
  2007-05-31 15:29 ` GenerateFold Nicolas Pouillard
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Reymont @ 2007-05-31 12:18 UTC (permalink / raw)
  To: OCaml List; +Cc: Nicolas Pouillard

What is the proper use of GenerateFold here?

What I'm trying to do is dig into my AST tree, starting with a list  
of statements at the top, to find out if I have any `FunArgDecl bits.

At the top of the AST I have

statement =
     [
     | `InputDecls of input_decl list
     ]

and then

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

I tried the following approach but it's obviously wrong.

class fold = Camlp4Filters.GenerateFold.generated;;

let is_fun_arg = object
   inherit fold as super
   method input_decl x =
     match super#input_decl x with
       | `FunArgDecl _ -> true
       | _             -> false
end

let is_fun x = is_fun_arg#statement x;;

	Thanks, Joel

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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 12:18 GenerateFold Joel Reymont
@ 2007-05-31 15:29 ` Nicolas Pouillard
  2007-05-31 17:41   ` GenerateFold Joel Reymont
  2007-05-31 18:58   ` GenerateFold Joel Reymont
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Pouillard @ 2007-05-31 15:29 UTC (permalink / raw)
  To: Joel Reymont; +Cc: OCaml List

On 5/31/07, Joel Reymont <joelr1@gmail.com> wrote:
> What is the proper use of GenerateFold here?
>
> What I'm trying to do is dig into my AST tree, starting with a list
> of statements at the top, to find out if I have any `FunArgDecl bits.
>
> At the top of the AST I have
>
> statement =
>      [
>      | `InputDecls of input_decl list
>      ]
>
> and then
>
> input_decl =
>      [
>      | `InputDecl of id * ty * expr
>      | `FunArgDecl of id * ty * subscript
>      ]
>
> I tried the following approach but it's obviously wrong.
>
> class fold = Camlp4Filters.GenerateFold.generated;;
>
> let is_fun_arg = object
>    inherit fold as super
>    method input_decl x =
>      match super#input_decl x with
>        | `FunArgDecl _ -> true
>        | _             -> false
> end
>
> let is_fun x = is_fun_arg#statement x;;
>

You must use the object itself that is threaded through the traversal
(or use an exception in that simple case).

Something like (not tested).

class fold = Camlp4Filters.GenerateFold.generated;;

let is_fun_arg = object
   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;;



-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 15:29 ` GenerateFold Nicolas Pouillard
@ 2007-05-31 17:41   ` Joel Reymont
  2007-05-31 18:58   ` GenerateFold Joel Reymont
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Reymont @ 2007-05-31 17:41 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: OCaml List

Nicolas,

On May 31, 2007, at 4:29 PM, Nicolas Pouillard wrote:

> You must use the object itself that is threaded through the traversal
> (or use an exception in that simple case).

How can I troubleshoot this resulting error?

+ ocamlfind ocamlc -package 'oUnit, dyp, extlib' -c -I +camlp4 -g -w  
a -pp 'camlp4of -I src -filter map -filter fold -filter trash ' -I  
src -o src/easy_type_check.cmo src/easy_type_check.ml
File "ghost-location", line 1, characters 0-0:
This expression has type
   < _Lexing_position : Lexing.position -> 'a;
     array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a;
     array_decl : Easy_ast.array_decl -> 'a;
     bar_prop : Easy_ast.bar_prop -> 'a; bars_ago : Easy_ast.bars_ago  
-> 'a;
     bool : bool -> 'a; color : Easy_ast.color -> 'a;
     cond : Easy_ast.cond -> 'a; direction : Easy_ast.direction -> 'a;
     exec_method : Easy_ast.exec_method -> 'a; expr : Easy_ast.price - 
 > 'a;
     float : float -> 'a; id : Easy_ast.id -> 'a;
     input_decl : Easy_ast.input_decl -> 'a;
     instrument : Easy_ast.instrument -> 'a; int : int -> 'a;
     list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
     option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a;
     order : Easy_ast.order -> 'a; order_type : Easy_ast.order_type - 
 > 'a;
     pos : Easy_ast.pos -> 'a; price : Easy_ast.price -> 'a;
     program : Easy_ast.program -> 'a;
     ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
     shares : Easy_ast.shares -> 'a; statement : Easy_ast.statement - 
 > 'a;
     string : string -> 'a; style : Easy_ast.style -> 'a;
     subscript : Easy_ast.subscript -> 'a; ty : Easy_ast.ty -> 'a;
     var_decl : Easy_ast.var_decl -> 'a; .. >
   as 'a
but is here used with type Easy_ast.order_type
Command exited with code 2.

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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 15:29 ` GenerateFold Nicolas Pouillard
  2007-05-31 17:41   ` GenerateFold Joel Reymont
@ 2007-05-31 18:58   ` Joel Reymont
  2007-05-31 22:05     ` GenerateFold Nicolas Pouillard
  1 sibling, 1 reply; 13+ messages in thread
From: Joel Reymont @ 2007-05-31 18:58 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: OCaml List

I can remove everything but class fold = ... in my code [1] but I  
would still get the error I mentioned previously. Is there an issue  
with GenerateFold?

	Thanks, Joel

[1] Code...

(* Remove annotations for unit testing *)

class map = Camlp4Filters.GenerateMap.generated;;

let strip_token_loc = object
   inherit map as super
   method expr e =
     match super#expr e with
       | `TokenPos (a, _) -> a
       | e                -> e
end

let strip_stmt x = strip_token_loc#statement x;;

class fold = Camlp4Filters.GenerateFold.generated;;

let is_fun_arg = object
   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 "easy_ast.ml";;
end;;


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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 18:58   ` GenerateFold Joel Reymont
@ 2007-05-31 22:05     ` Nicolas Pouillard
  2007-05-31 22:16       ` GenerateFold Joel Reymont
  2007-05-31 22:34       ` GenerateFold Joel Reymont
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Pouillard @ 2007-05-31 22:05 UTC (permalink / raw)
  To: Joel Reymont; +Cc: OCaml List

On 5/31/07, Joel Reymont <joelr1@gmail.com> wrote:
> I can remove everything but class fold = ... in my code [1] but I
> would still get the error I mentioned previously. Is there an issue
> with GenerateFold?
>
>         Thanks, Joel
>
> [1] Code...
>
> (* Remove annotations for unit testing *)
>
> class map = Camlp4Filters.GenerateMap.generated;;
>
> let strip_token_loc = object
>    inherit map as super
>    method expr e =
>      match super#expr e with
>        | `TokenPos (a, _) -> a
>        | e                -> e
> end
>
> let strip_stmt x = strip_token_loc#statement x;;
>
> class fold = Camlp4Filters.GenerateFold.generated;;
>
> let is_fun_arg = object

self is missing

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 "easy_ast.ml";;
> end;;
>
>
> --
> http://topdog.cc      - EasyLanguage to C# translator
> http://wagerlabs.com  - Blog
>
>
>
>
>
>


-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 22:05     ` GenerateFold Nicolas Pouillard
@ 2007-05-31 22:16       ` Joel Reymont
  2007-05-31 22:34       ` GenerateFold Joel Reymont
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Reymont @ 2007-05-31 22:16 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: OCaml List

Nicolas,

Could there be some other reason for this error? I comment out  
everything but the "fold" and still get it.

	Thanks, Joel

---

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 "easy_ast.ml";;
end;;

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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: GenerateFold
  2007-05-31 22:05     ` GenerateFold Nicolas Pouillard
  2007-05-31 22:16       ` GenerateFold Joel Reymont
@ 2007-05-31 22:34       ` Joel Reymont
  2007-06-01  6:08         ` [Caml-list] GenerateFold Edgar Friendly
  1 sibling, 1 reply; 13+ messages in thread
From: Joel Reymont @ 2007-05-31 22:34 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: OCaml List

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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-05-31 22:34       ` GenerateFold Joel Reymont
@ 2007-06-01  6:08         ` Edgar Friendly
  2007-06-01 13:22           ` Joel Reymont
  0 siblings, 1 reply; 13+ messages in thread
From: Edgar Friendly @ 2007-06-01  6:08 UTC (permalink / raw)
  To: Joel Reymont; +Cc: Nicolas Pouillard, OCaml List

Joel Reymont wrote:
> 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

Obscure functionality.  It's object cloning (of self), with a modified
instance variable.  See 3.14 of the ocaml manual

E.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-06-01  6:08         ` [Caml-list] GenerateFold Edgar Friendly
@ 2007-06-01 13:22           ` Joel Reymont
  2007-06-01 13:30             ` Nicolas Pouillard
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Reymont @ 2007-06-01 13:22 UTC (permalink / raw)
  To: OCaml List

I figured it out. The following introduction of order and order_type  
[2] triggers the error I was seeing previously [1]. This should be  
enough to reproduce the issue and, hopefully, provide clues on how to  
fix it. I have no clues, btw.

	Thanks, Joel

[1] Error

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 "ghost-location", line 1, characters 0-0:
This expression has type
   < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a;
     expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a;
     input_decl : A.input_decl -> 'a; int : int -> 'a;
     list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
     option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order :  
A.order -> 'a;
     order_type : A.order_type -> 'a; program : A.program -> 'a;
     ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
     statement : A.statement -> 'a; string : string -> 'a;
     subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. >
   as 'a
but is here used with type A.order_type

[2] Code with order and order_type.

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
     ]

and order = {
   order_type: order_type;
}

and order_type =
     [
     | `Buy
     | `Sell
     | `Short
     | `Cover
     ]



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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-06-01 13:22           ` Joel Reymont
@ 2007-06-01 13:30             ` Nicolas Pouillard
  2007-06-01 13:44               ` Joel Reymont
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Pouillard @ 2007-06-01 13:30 UTC (permalink / raw)
  To: Joel Reymont; +Cc: OCaml List

Got it:

There is the solution available for meditation :)

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


On 6/1/07, Joel Reymont <joelr1@gmail.com> wrote:
> I figured it out. The following introduction of order and order_type
> [2] triggers the error I was seeing previously [1]. This should be
> enough to reproduce the issue and, hopefully, provide clues on how to
> fix it. I have no clues, btw.
>
>         Thanks, Joel
>
> [1] Error
>
> 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 "ghost-location", line 1, characters 0-0:
> This expression has type
>    < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a;
>      expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a;
>      input_decl : A.input_decl -> 'a; int : int -> 'a;
>      list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
>      option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order :
> A.order -> 'a;
>      order_type : A.order_type -> 'a; program : A.program -> 'a;
>      ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
>      statement : A.statement -> 'a; string : string -> 'a;
>      subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. >
>    as 'a
> but is here used with type A.order_type
>
> [2] Code with order and order_type.
>
> 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
>      ]
>
> and order = {
>    order_type: order_type;
> }
>
> and order_type =
>      [
>      | `Buy
>      | `Sell
>      | `Short
>      | `Cover
>      ]
>
>
>
> --
> http://topdog.cc      - EasyLanguage to C# translator
> http://wagerlabs.com  - Blog
>

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-06-01 13:30             ` Nicolas Pouillard
@ 2007-06-01 13:44               ` Joel Reymont
  2007-06-01 16:07                 ` Nicolas Pouillard
  0 siblings, 1 reply; 13+ messages in thread
From: Joel Reymont @ 2007-06-01 13:44 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: OCaml List

Doesn't work!

On Jun 1, 2007, at 2:30 PM, Nicolas Pouillard wrote:

> Got it:
>
> There is the solution available for meditation :)

To be precise, I don't know if it works or not. I think the fold  
generator bombs out.

I have no idea how to debug this but, again, it has nothing to do  
with the implementation of is_fun_arg.

Simply using GenerateFold triggers the error. Notice that everything  
but class fold = ... is commented out. I'm including everything  
needed to reproduce the error, just in case.

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 "ghost-location", line 1, characters 0-0:
This expression has type
   < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a;
     expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a;
     input_decl : A.input_decl -> 'a; int : int -> 'a;
     list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
     option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order :  
A.order -> 'a;
     order_type : A.order_type -> 'a; program : A.program -> 'a;
     ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
     statement : A.statement -> 'a; string : string -> 'a;
     subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. >
   as 'a
but is here used with type A.order_type

cat b.ml
open A

class fold = Camlp4Filters.GenerateFold.generated;;

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

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

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

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
     ]

and order = {
   order_type: order_type;
}

and order_type =
     [
     | `Buy
     | `Sell
     | `Short
     | `Cover
     ]

cat c.ml
open A
open B

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


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






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-06-01 13:44               ` Joel Reymont
@ 2007-06-01 16:07                 ` Nicolas Pouillard
  2007-06-05 12:25                   ` Nicolas Pouillard
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Pouillard @ 2007-06-01 16:07 UTC (permalink / raw)
  To: Joel Reymont; +Cc: OCaml List

Ok there is a bug in the fold generation we using records, but the
previous example (without records) compiled fine for me. So
records+fold is buggy for now.

On 6/1/07, Joel Reymont <joelr1@gmail.com> wrote:
> Doesn't work!
>
> On Jun 1, 2007, at 2:30 PM, Nicolas Pouillard wrote:
>
> > Got it:
> >
> > There is the solution available for meditation :)
>
> To be precise, I don't know if it works or not. I think the fold
> generator bombs out.
>
> I have no idea how to debug this but, again, it has nothing to do
> with the implementation of is_fun_arg.
>
> Simply using GenerateFold triggers the error. Notice that everything
> but class fold = ... is commented out. I'm including everything
> needed to reproduce the error, just in case.
>
> 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 "ghost-location", line 1, characters 0-0:
> This expression has type
>    < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a;
>      expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a;
>      input_decl : A.input_decl -> 'a; int : int -> 'a;
>      list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
>      option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order :
> A.order -> 'a;
>      order_type : A.order_type -> 'a; program : A.program -> 'a;
>      ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
>      statement : A.statement -> 'a; string : string -> 'a;
>      subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. >
>    as 'a
> but is here used with type A.order_type
>
> cat b.ml
> open A
>
> class fold = Camlp4Filters.GenerateFold.generated;;
>
> (*
> let is_fun_arg = object
> inherit fold as super
> val found = false
> method found = found
> method input_decl x =
>     match x with
>       | `FunArgDecl _ -> {< found = true >}
>       | _             -> super#input_decl x
> end
>
> let is_fun x = (is_fun_arg#statement x)#found;;
> *)
>
> module Camlp4Trash = struct
>    INCLUDE "a.ml";;
> end;;
>
> 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
>      ]
>
> and order = {
>    order_type: order_type;
> }
>
> and order_type =
>      [
>      | `Buy
>      | `Sell
>      | `Short
>      | `Cover
>      ]
>
> cat c.ml
> open A
> open B
>
> cat _tags
> "b.ml": use_camlp4, pp(camlp4of -I src -filter map -filter fold -
> filter trash )
>
>
> --
> http://topdog.cc      - EasyLanguage to C# translator
> http://wagerlabs.com  - Blog
>
>
>
>
>
>


-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Caml-list] Re: GenerateFold
  2007-06-01 16:07                 ` Nicolas Pouillard
@ 2007-06-05 12:25                   ` Nicolas Pouillard
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Pouillard @ 2007-06-05 12:25 UTC (permalink / raw)
  To: Joel Reymont; +Cc: OCaml List

I've fixed the fold generation for record types in the CVS.

On 6/1/07, Nicolas Pouillard <nicolas.pouillard@gmail.com> wrote:
> Ok there is a bug in the fold generation we using records, but the
> previous example (without records) compiled fine for me. So
> records+fold is buggy for now.
>
> On 6/1/07, Joel Reymont <joelr1@gmail.com> wrote:
> > Doesn't work!
> >
> > On Jun 1, 2007, at 2:30 PM, Nicolas Pouillard wrote:
> >
> > > Got it:
> > >
> > > There is the solution available for meditation :)
> >
> > To be precise, I don't know if it works or not. I think the fold
> > generator bombs out.
> >
> > I have no idea how to debug this but, again, it has nothing to do
> > with the implementation of is_fun_arg.
> >
> > Simply using GenerateFold triggers the error. Notice that everything
> > but class fold = ... is commented out. I'm including everything
> > needed to reproduce the error, just in case.
> >
> > 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 "ghost-location", line 1, characters 0-0:
> > This expression has type
> >    < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a;
> >      expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a;
> >      input_decl : A.input_decl -> 'a; int : int -> 'a;
> >      list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a;
> >      option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order :
> > A.order -> 'a;
> >      order_type : A.order_type -> 'a; program : A.program -> 'a;
> >      ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a;
> >      statement : A.statement -> 'a; string : string -> 'a;
> >      subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. >
> >    as 'a
> > but is here used with type A.order_type
> >
> > cat b.ml
> > open A
> >
> > class fold = Camlp4Filters.GenerateFold.generated;;
> >
> > (*
> > let is_fun_arg = object
> > inherit fold as super
> > val found = false
> > method found = found
> > method input_decl x =
> >     match x with
> >       | `FunArgDecl _ -> {< found = true >}
> >       | _             -> super#input_decl x
> > end
> >
> > let is_fun x = (is_fun_arg#statement x)#found;;
> > *)
> >
> > module Camlp4Trash = struct
> >    INCLUDE "a.ml";;
> > end;;
> >
> > 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
> >      ]
> >
> > and order = {
> >    order_type: order_type;
> > }
> >
> > and order_type =
> >      [
> >      | `Buy
> >      | `Sell
> >      | `Short
> >      | `Cover
> >      ]
> >
> > cat c.ml
> > open A
> > open B
> >
> > cat _tags
> > "b.ml": use_camlp4, pp(camlp4of -I src -filter map -filter fold -
> > filter trash )
> >
> >
> > --
> > http://topdog.cc      - EasyLanguage to C# translator
> > http://wagerlabs.com  - Blog
> >
> >
> >
> >
> >
> >
>
>
> --
> Nicolas Pouillard
>


-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-06-05 12:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-31 12:18 GenerateFold Joel Reymont
2007-05-31 15:29 ` GenerateFold Nicolas Pouillard
2007-05-31 17:41   ` GenerateFold Joel Reymont
2007-05-31 18:58   ` GenerateFold Joel Reymont
2007-05-31 22:05     ` GenerateFold Nicolas Pouillard
2007-05-31 22:16       ` GenerateFold Joel Reymont
2007-05-31 22:34       ` GenerateFold Joel Reymont
2007-06-01  6:08         ` [Caml-list] GenerateFold Edgar Friendly
2007-06-01 13:22           ` Joel Reymont
2007-06-01 13:30             ` Nicolas Pouillard
2007-06-01 13:44               ` Joel Reymont
2007-06-01 16:07                 ` Nicolas Pouillard
2007-06-05 12:25                   ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).