caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] with clause
@ 2011-10-07 16:37 Walter Cazzola
  2011-10-09 15:42 ` Gabriel Scherer
  0 siblings, 1 reply; 2+ messages in thread
From: Walter Cazzola @ 2011-10-07 16:37 UTC (permalink / raw)
  To: OCaML Mailing List

[-- Attachment #1: Type: TEXT/PLAIN, Size: 651 bytes --]

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

-- 

[-- Attachment #2: Type: TEXT/PLAIN, Size: 101 bytes --]

module type OpVarADT = 
 sig
   type a and b and c
   val op: a -> b -> c
   val init : c
 end

[-- Attachment #3: Type: TEXT/PLAIN, Size: 161 bytes --]

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

[-- Attachment #4: Type: TEXT/PLAIN, Size: 132 bytes --]

module ListConcat = struct
  type a and b = a list and c = a list
  let op = fun (x: a) y -> y @ [x] ;;
  let init = [] ;;
end

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

end of thread, other threads:[~2011-10-09 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 16:37 [Caml-list] with clause Walter Cazzola
2011-10-09 15:42 ` Gabriel Scherer

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).