Dear all,
I'm still stucked on my example to write a functor for functions with a
variable number of arguments. In particular I can't instantiate it with
a generic list ('a list).
Attached you find my code. Sometimes ago some on the list suggested me
to use with to specify the value of the generic type (a in my case but
I can't get rid of its syntax, what I think correct is:
module M1 = VarArgs(ListConcat with type ListConcat.a = int) ;;
but I get a syntax error on the with.
Please note that I'd like to keep OpVarADT and varargs independent of
the concrete type of a.
Any help to solve this riddle would be appreciated.
TIA
Walter
--
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
module type OpVarADT =
sig
type a and b and c
val op: a -> b -> c
val init : c
end
module VarArgs (OP : OpVarADT.OpVarADT) =
struct
let arg x = fun y rest -> rest (OP.op x y) ;;
let stop x = x;;
let f g = g OP.init;;
end
module ListConcat = struct
type a and b = a list and c = a list
let op = fun (x: a) y -> y @ [x] ;;
let init = [] ;;
end