You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5446 Reporter: pilki Assigned to:@garrigue Status: closed (set by @garrigue on 2011-12-24T03:21:15Z) Resolution: not a bug Severity: feature Category: ~DO NOT USE (was: OCaml general) Child of:#5444 Monitored by:@protz
Bug description
Say you give fancy names for type variables in a type definition:
<<<
type ('fst, 'snd) mypair = MkMyPair of 'fst * 'snd
those type variables are not used for inference. For example:
<<<
let mk x y = MkMyPair (x, y)
The infered type is
val mk : 'a -> 'b -> ('a, 'b) mypair
and one might expect to have
val mk: 'fst -> 'snd -> ('fst, 'snd) mypair
Additional information
I don't know what would be a nice "specification" for such a feature. What for example should be the type of
let swap (MkMyPair (x, y)) = MkMyPair (y, x)
val swap : ('fst, 'snd) mypair -> ('snd, 'fst) mypair
or
val swap : ('snd, 'fst) mypair -> ('fst, 'snd) mypair
What when you have several instance of the same type constructor with different type variables ? Add a 0, 1.. ? then every function on lists would have types of the form
val map: ('a -> 'a0) -> 'a list -> 'a0 list
I do not know if this is solvable.
The text was updated successfully, but these errors were encountered:
Same comment as #5447.
I'm not sure inheriting variable names from type definitions makes sense.
.@pilki Considering backward compatibility, it would be more reasonable to have no inheritance by default.
But introduce new syntax for explicit inheritance seems an overkill.
Using something like "only inherit names of 2 characters or more" might be an option.
Original bug ID: 5446
Reporter: pilki
Assigned to: @garrigue
Status: closed (set by @garrigue on 2011-12-24T03:21:15Z)
Resolution: not a bug
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Child of: #5444
Monitored by: @protz
Bug description
Say you give fancy names for type variables in a type definition:
<<<
type ('fst, 'snd) mypair = MkMyPair of 'fst * 'snd
those type variables are not used for inference. For example:
<<<
let mk x y = MkMyPair (x, y)
The infered type is
val mk : 'a -> 'b -> ('a, 'b) mypair
and one might expect to have
val mk: 'fst -> 'snd -> ('fst, 'snd) mypair
Additional information
I don't know what would be a nice "specification" for such a feature. What for example should be the type of
let swap (MkMyPair (x, y)) = MkMyPair (y, x)
val swap : ('fst, 'snd) mypair -> ('snd, 'fst) mypair
or
val swap : ('snd, 'fst) mypair -> ('fst, 'snd) mypair
What when you have several instance of the same type constructor with different type variables ? Add a 0, 1.. ? then every function on lists would have types of the form
val map: ('a -> 'a0) -> 'a list -> 'a0 list
I do not know if this is solvable.
The text was updated successfully, but these errors were encountered: