caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Walter Cazzola <cazzola@dico.unimi.it>
To: OCaML Mailing List <caml-list@inria.fr>
Subject: [Caml-list] with clause
Date: Fri, 7 Oct 2011 18:37:16 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1110071828480.3251@surtur.dico.unimi.it> (raw)

[-- 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

             reply	other threads:[~2011-10-07 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07 16:37 Walter Cazzola [this message]
2011-10-09 15:42 ` Gabriel Scherer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.00.1110071828480.3251@surtur.dico.unimi.it \
    --to=cazzola@dico.unimi.it \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).