[MLton] withtype in signature?

Wesley W.Terpstra wesley@terpstra.ca
Tue, 6 Sep 2005 14:14:41 +0200


On Sep 6, 2005, at 1:58 PM, Matthew Fluet wrote:

>> Why is 'withtype' not allowed in signatures? The standard?
>>
> Correct.  The grammar of the Definition does not admit "withtype"  
> in signatures.
>

Do you know why they've done that?
It seems like *more* work to forbid withtype in (only) sig context.


>> How do I achieve the same effect? (a public recursive datatype)
>> I know that I could simply replace all the occurrences of foo
>> and baz in the public definition, like:
>>
>
> That is one recourse.  Another, almost as verbose means is to  
> define a structure with exactly the datatype of interest and then  
> bind to that in the signature:
>
> structure T = struct
>   datatype test = A of foo * baz | B
>   withtype foo = string * test
>   and baz = int
> end
>
> signature S = sig
>   datatype test = datatype T.test
>   type foo = T.foo
>   type baz = T.baz
> end
>

For my situation, that's almost an improvement...
However, since datatypes are generative, I have to
use exactly T's datatype in a matching structure..?

structure Foo : S =
   struct
     datatype test = A of foo * baz | B
     withtype foo = string * test
     and baz = int
   end
won't work. I need to 'open T', right? That's unpleasant.


>> However, this seems rather silly; in the real source code, the
>> abbreviation greatly improves readability and brevity. One would
>> think that is most important in the context of signatures...
>>
>
> Agreed, but when every implementation throws in conveniences for  
> what its developers encounter, you end up with the fractured  
> landscape of SML+<extension> and portability problems.
>

I never proposed to extend SML! :-) I just wanted to know if this was
a bug and/or the reasoning for it, if not a bug. What I am hoping is  
that
the standard ruled it out because it was unnecessary in a way I just  
don't
see yet. Ideas?