[MLton] Extending the SML Basis library (Library project)
Stephen Weeks
sweeks at sweeks.com
Tue Oct 17 16:03:07 PDT 2006
> > signature ISO = sig
> > type ('a, 'b) t
> [...]
> > val make: ('a -> 'b) * ('b -> 'a) -> ('a, 'b) t
> [...]
> > end
>
> The major problem (sorry for the repetition if you already spotted this
> from my earlier post) with this design (making Iso.t an abstract type) is
> that one can no longer make polymorphic isomorphisms (courtesy of the
> value restriction). For example, it would be impossible to implement a
> structure matching the following signature (from my earlier message):
>
> signature VECTOR =
> sig
> include VECTOR
> val list : ('a vector, 'a list) iso
> val toList : 'a vector -> 'a list
> end
>
> So, IMO, the iso/emb types must be concrete.
In my experience, relying on the value restriction, which is quite
syntactically sensitive, is often, although not always, a design
mistake. It might be better to specify Vector.list as
val list : unit -> ('a vector, 'a list) iso
which then allows one to do things (like call Iso.make) when building
the isomorphism, and is more robust to underlying implementation
changes.
> (BTW, I'm using Iso.iso rather than Iso.t, which I usually prefer, to be
> consistent with the basis library style.)
Makes sense (in a basis library extension).
More information about the MLton
mailing list