From: skaller <skaller@users.sourceforge.net>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Private types
Date: 02 May 2004 07:11:43 +1000 [thread overview]
Message-ID: <1083445902.20722.149.camel@pelican.wigram> (raw)
In-Reply-To: <1083444008.20722.135.camel@pelican.wigram>
Ahh, well this works:
module type M_t = sig
type 'a t = private { x: 'a list }
val uniq_cons: 'a t -> 'a -> 'a t
val empty: unit -> 'a t
end
module M : M_t = struct
type 'a t = { x : 'a list }
let uniq_cons lst a = if List.mem a lst.x then lst else { x = a::lst.x }
let empty () = { x = [] }
end
let x = M.empty ()
let x = M.uniq_cons x 1
let x = M.uniq_cons x 1
let x = M.uniq_cons x 2
let print { M.x=x } = print_endline (
"[" ^
String.concat "," (List.map string_of_int x) ^
"]"
)
;; print x
;;
[skaller@pelican] /mnt/user2/work/flx>ocaml xx.ml
[2,1]
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2004-05-01 21:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-28 15:28 [Caml-list] Reading a large text file André Luiz Moura
2004-04-28 16:28 ` Richard Jones
2004-05-01 14:03 ` Brian Hurt
2004-05-01 15:43 ` Rahul Siddharthan
2004-05-01 16:00 ` [Caml-list] [OcamlDoc] langage support sejourne kevin
2004-05-14 7:15 ` Maxence Guesdon
2004-05-01 18:05 ` [Caml-list] Reading a large text file Richard Jones
2004-05-01 18:25 ` Charles Forsyth
2004-05-01 19:25 ` skaller
2004-05-01 19:51 ` Alain.Frisch
2004-05-01 20:40 ` skaller
2004-05-01 21:11 ` skaller [this message]
2004-05-01 21:33 ` Alain.Frisch
2004-05-17 5:28 ` Eric Stokes
2008-10-30 20:18 Private types David Allsopp
2008-10-30 20:33 ` [Caml-list] " Daniel Bünzli
2008-10-30 21:54 ` David Allsopp
2008-10-31 0:08 ` Jacques Garrigue
2008-10-31 14:05 ` Dario Teixeira
2008-11-01 9:52 ` Jacques Garrigue
2008-11-01 1:52 ` Edgar Friendly
2008-11-01 8:19 ` David Allsopp
2008-11-01 19:31 ` Edgar Friendly
2008-11-01 20:18 ` David Allsopp
2008-11-02 14:53 ` Edgar Friendly
2008-11-01 10:00 ` Jacques Garrigue
2008-11-01 19:41 ` Edgar Friendly
2008-10-30 21:47 ` Jérémie Dimino
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=1083445902.20722.149.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--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