Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#184] Difference between mlton/sml-nj in type generalization

Date:
2017-06-11 13:28
Priority:
3
State:
Closed
Submitted by:
Bug Submitter (webuser)
Assigned to:
David MacQueen (dbm)
Machine Architecture:
None
Operating System:
All
Component:
Compiler
Resolution:
Won't Fix
Severity:
Cosmetic
OS Version:
SML/NJ Version:
110.81
Keywords:
URL:
Transcript (of reproduction):
Standard ML of New Jersey v110.81 [built: Sun Jun 11 05:04:27 2017] [opening silly.sml] val id = fn : 'a -> 'a val curry = fn : ('a * 'b -> 'c) -> 'a -> 'b -> 'c val foo = fn : int * (bool * (unit * real)) -> unit silly.sml:6.5-6.20 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) silly.sml:7.11-7.19 Error: operator and operand don't agree [tycon mismatch] operator domain: 'Z * 'Y -> 'X operand: ?.X1 -> int * ?.X1 in expression: curry it
Source (for reproduction):
fun id x = x fun curry f x y = f (x, y) fun foo (w : int, (x : bool, (y : unit, z : real))) = (); val it = curry id 0 val it = (curry it) true val it = (curry it) () val it = it 0.0 val _ = foo it;
Summary:
Difference between mlton/sml-nj in type generalization

Detailed description
In a silly example there is an observable difference between SML/NJ and MLton,
SML/NJ rejects the code, while MLTon accepts it,

I'm not quite sure though one or both may conform to the standard,
with differing interpretations of the value restriction context.


Additional comments:
Perhaps everything is conforming and this can be closed without change.
I just figured I would point it out.

Submitted via web form by matt rice <ratmice@gmail.com>

Comments:

Message  ↓
Date: 2017-08-28 14:31
Sender: John Reppy

The Definition of Standard ML is ambiguous w.r.t. this question (also the scope of overload resolution).

Attached Files:

Changes

Field Old Value Date By
status_idOpen2017-08-28 14:31jhr
close_dateNone2017-08-28 14:31jhr
assigned_tonone2017-08-28 14:31jhr
detailsIn a silly example there is an observable difference between SML/NJ and MLton, SML/NJ rejects the code, while MLTon accepts it, I'm not quite sure though one or both may conform to the standard, with differing interpretations of the value restriction context. Additional comments: Perhaps everything is conforming and this can be closed without change. I just figured I would point it out. Submitted via web form by matt rice <ratmice@gmail.com> 2017-08-28 14:31jhr
Operating SystemGeneric Unix2017-08-28 14:31jhr
ResolutionNone2017-08-28 14:31jhr
Transcript (of reproduction)Standard ML of New Jersey v110.81 [built: Sun Jun 11 05:04:27 2017] [opening silly.sml] val id = fn : 'a -> 'a val curry = fn : ('a * 'b -> 'c) -> 'a -> 'b -> 'c val foo = fn : int * (bool * (unit * real)) -> unit silly.sml:6.5-6.20 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) silly.sml:7.11-7.19 Error: operator and operand don't agree [tycon mismatch] operator domain: 'Z * 'Y -> 'X operand: ?.X1 -> int * ?.X1 in expression: curry it 2017-08-28 14:31jhr
Source (for reproduction)fun id x = x fun curry f x y = f (x, y) fun foo (w : int, (x : bool, (y : unit, z : real))) = (); val it = curry id 0 val it = (curry it) true val it = (curry it) () val it = it 0.0 val _ = foo it; 2017-08-28 14:31jhr