caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@best.com>
To: Francois Thomasset <Francois.Thomasset@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] le neophyte et les modules, types parametres
Date: Wed, 25 Apr 2001 09:16:29 -0700 (PDT)	[thread overview]
Message-ID: <Pine.BSF.4.21.0104250909360.26257-100000@shell5.ba.best.com> (raw)
In-Reply-To: <200104251549.f3PFn0116328@ionie.inria.fr>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1838 bytes --]

On Wed, 25 Apr 2001, Francois Thomasset wrote:
> Désolé de poser des qustions simplistes mais je suis perdu dans les modules.
> Dans l'idée de construire une table de symboles je définis ceci :
> # type symbol = string * int ;;
> # type comparison = Equiv | Smaller | Greater;;
> # module type ORDERED =
>     sig
>       type 'a t
>       val order : 'a t -> 'a t -> comparison
>     end;;
> module type ORDERED =
>   sig type 'a t val order : 'a t -> 'a t -> comparison end
> # module type AVL_FUNCTOR = functor ( Key : ORDERED ) ->
>   sig
>     type 'a key = 'a Key.t
>     type avl_btree = ('a key * int) btree
>     ...
>   end;;
> The type constructor Key.t expects 1 argument(s),
> but is here applied to 0 argument(s)
> 
> D'accord je suppose que c'est le type 'a qui manque (un jour ce sera les 
> morceaux d'environnement attachés aux symboles, donc je n'ai pas envie de 
> préciser tout de suite) ; mais je ne comprends pas comment le dire autrement 
> que ci-dessus ; quelque chose a du m'échapper...
> 
> Question: how to use a parameter type in a module, cf example above

That looks fine, other than the missing type parameter 'a in your
definition of avl_btree. That would give a different error message than
the one you show though, so I don't understand that message either. 

The following should compile:

type comparison = Equiv | Smaller | Greater;;

module type ORDERED =
  sig
    type 'a t
    val order : 'a t -> 'a t -> comparison
  end;;

type 'a btree = Leaf | Node of 'a * 'a btree * 'a btree;;

module type AVL_FUNCTOR = functor ( Key : ORDERED ) ->
  sig
    type 'a key = 'a Key.t
    type 'a avl_btree = ('a key * int) btree
  end;;

-- Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-04-25 16:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-25 15:49 Francois Thomasset
2001-04-25 16:16 ` Brian Rogoff [this message]
2001-04-25 16:20 ` Alain Frisch

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=Pine.BSF.4.21.0104250909360.26257-100000@shell5.ba.best.com \
    --to=bpr@best.com \
    --cc=Francois.Thomasset@inria.fr \
    --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).