From: "Jonathan Roewen" <jonathan.roewen@gmail.com>
To: "Bruno De Fraine" <Bruno.De.Fraine@vub.ac.be>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type from local module would escape its scope?
Date: Tue, 4 Jul 2006 03:10:28 +1200 [thread overview]
Message-ID: <ad8cfe7e0607030810k10f0f599rd9e5a1582e0523f0@mail.gmail.com> (raw)
In-Reply-To: <5E0B2C43-5EDD-423F-B2ED-8BC025596DC7@vub.ac.be>
> Thanks for your explanations! To get closer to the problem that
> caused me to investigate the error: so there is no way to make f1
> into an argument in the following function iter_uniques (other than
> as a method or record field)?
>
> let f1 add empty = List.fold_right add ["foo"; "bar"; "bar"] empty ;;
> let f2 = print_endline ;;
>
> let iter_uniques comparison_fun =
> let module StringSet =
> Set.Make(struct
> type t = string
> let compare = comparison_fun
> end) in StringSet.iter f2 (f1 StringSet.add StringSet.empty)
> ;;
Hmm, you could use a ref (which yes, is a record type).
let dyn_comparer = ref compare
let dyn_compare a b = !dyn_comparer a b
module SS = Set.Make(struct type t = string let compare = dyn_compare end);;
let iter_uniques f1 f2 = SS.iter f2 (f1 SS.add SS.empty);;
next prev parent reply other threads:[~2006-07-03 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-03 13:19 Bruno De Fraine
2006-07-03 13:23 ` [Caml-list] " Jonathan Roewen
2006-07-03 13:38 ` Jean-Marie Gaillourdet
2006-07-03 13:45 ` Alain Frisch
2006-07-03 13:51 ` Virgile Prevosto
2006-07-03 14:23 ` skaller
2006-07-03 14:50 ` Bruno De Fraine
2006-07-03 15:10 ` Jonathan Roewen [this message]
2006-07-03 17:30 ` Petty complaint (Was Re: [Caml-list] Type from local module would escape its )scope? brogoff
2006-07-03 18:50 ` Etienne Miret
2006-07-04 21:08 ` Boris Yakobowski
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=ad8cfe7e0607030810k10f0f599rd9e5a1582e0523f0@mail.gmail.com \
--to=jonathan.roewen@gmail.com \
--cc=Bruno.De.Fraine@vub.ac.be \
--cc=caml-list@yquem.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