[MLton-user] Re: More Extended Basis Library
Vesa Karvonen
vesa.a.j.k at gmail.com
Sun Mar 4 11:14:45 PST 2007
On 3/4/07, Geoffrey Alan Washburn <geoffw at cis.upenn.edu> wrote:
> Somewhat tangentially related, do you think there would be much interest
> in signatures that talk about properties of a non-parameterized
> datatype?
I'm not sure that I understand the idea you are trying to communicate
here. Are you perhaps talking about some kind of datatype generic
programming or perhaps a kind of introspection? How would one use a
module that implements one or more of the kind of signatures that you are
talking about?
Most of the current concept signatures (e.g ORDERED, STRINGABLE, SIGNED,
...) describe properties of non-parameterized types.
Usually an interesting concept signature specifies a set of properties
that is common to many types (or modules). Having a single specification
of the concept makes it easier (both conceptually and technically) to deal
with all the instances of the concept.
> For example, one could write a signature
>
> signature HAS_PRODUCTS
> type u
> include PRODUCT_TYPE where ('a, 'b) t = u
> end
>
> but that isn't really what you would like. In this situation you would
> like something more like
>
> signature HAS_PRODUCTS
> type t
> val fromTuple2 : t * t -> t
> ...
> end
>
> However, I'm not sure offhand where there is a reasonable way to unify a
> »HAS_PRODUCTS« signature with the »PRODUCT_TYPE« signature without
> duplication. »HAS_PRODUCTS« also seems more like a »concept« signature
> than a »data« signature. Perhaps someone with more experience making
> clever use of the module system might have an idea.
>
> In any event, go forward from there it would probably be useful to
> define signatures like HAS_UNIT and IS_CARTESIAN, etc.
Like I said, I'm not sure that I understand the idea. Let's say that a
type (module defining the type) would implement both HAS_PRODUCTS and
HAS_UNIT. Would this mean that it has constructors with the types
t * t -> t
and
unit -> t
An example of such a datatype would be, for example,
datatype t = PRODUCT of t * t | UNIT .
IOW, the idea is that one would specify the structure of a datatype using
the signatures. If this is roughly the idea, then I think that one or
more of the ways of encoding type-indexed values might be more practical.
See, for example,
http://mlton.org/TypeIndexedValues
http://mlton.org/pipermail/mlton-user/2006-September/000914.html
-Vesa Karvonen
More information about the MLton-user
mailing list