Re: A datatype that is, and is not, an equality type?
Adam Chlipala <[email protected]>
| Newsgroups | gmane.comp.lang.ml.mlton.user |
|---|---|
| Message-ID | <[email protected]> |
On 09/01/2013 08:27 AM, Phil Clayton wrote:
> However, none of them accept
>
> signature S =
> sig
> eqtype 'a t
> val eq : 'a t * 'b t -> bool
> end
>
> structure S :> S =
> struct
> datatype 'a t = A of int
> fun eq (a, b) = a = b
> end
>
> on the grounds that 'a t is _not_ an equality type!
>
That's not what I see from SML/NJ, and not what I'd expect from my
understanding of SML. Rather, the issue with [eq] is that equality only
works on two operands of the _same_ type, whereas here you are trying to
apply it on values of _different_ types ['a t] and ['b t]. This notion
of "different" comes from SML's basic semantics of datatype declarations.
As we would expect from that explanation, the following module
definition works fine:
structure S :> S =
struct
datatype t' = A of int
type 'a t = t'
fun eq (a, b) = a = b
end
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk