caml-list - the Caml user's mailing list
 help / Atom feed
* [Caml-list] Type That's Concrete From Within A Library Abstract From Without
@ 2018-04-26 14:18 Jun Inoue
  2018-04-26 14:28 ` Malcolm Matalka
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Jun Inoue @ 2018-04-26 14:18 UTC (permalink / raw)
  To: caml list

Dear list,

Is there a way to make a type concrete inside a library, yet opaque to
library users, preferably in a way that works with -pack?  This is a
nagging issue in our sundials package
(http://inria-parkas.github.io/sundialsml/).

Basically, we have a type declared in one module of the library that
is pattern-matched upon in other modules, like:

(* private.ml *)
type opaque_type = Foo | Bar

(* public.ml *)
let f : opaque_type -> int = function
  | Foo -> 0
  | Bar -> 1

There are a few constraints:
- We don't want users to be able to pattern-match on opaque_type.
- We need multiple modules in the library to pattern-match on
opaque-type (so moving opaque_typ e to public.ml is not an option).
- To avoid namespace pollution, we want to pack the whole library
(with ocamlc -pack) as a single Sundials module, so the user sees a
Sundials.Public module instead of just Public.

Is this possible?  Right now, we just collect public.cmo and
private.cmo into sundials.cma and throw away private.cmi.  But this
doesn't work with packing:

$ ocamlc -pack -o sundials.cmo private.cmo public.cmo

demands that there be a private.cmi.

-- 
Jun Inoue

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

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

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 14:18 [Caml-list] Type That's Concrete From Within A Library Abstract From Without Jun Inoue
2018-04-26 14:28 ` Malcolm Matalka
2018-04-26 15:04 ` Nicolás Ojeda Bär
2018-04-26 15:14   ` Nicolás Ojeda Bär
2018-07-06  8:08   ` Timothy Bourke
2018-07-06  8:44     ` Gabriel Scherer
2018-07-06  9:05       ` Timothy Bourke
2018-04-26 15:06 ` Ivan Gotovchits
2018-04-27  5:49   ` Jun Inoue
2018-04-27  6:06     ` Jacques Garrigue
2018-04-27  8:53       ` Jun Inoue
2018-04-27 11:21         ` Elie Canonici Merle
2018-04-29 10:39         ` Mikhail Mandrykin

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox