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: 6569 Reporter:@lpw25 Assigned to:@garrigue Status: closed (set by @xavierleroy on 2016-12-07T10:36:58Z) Resolution: not a bug Priority: normal Severity: feature Version: 4.02.0 Category: typing Related to:#6673 Monitored by:@hcarty
Bug description
The following definition fails:
# let foo : 'a. 'a list -> unit =
fun (x : 'a list) -> ();;
Characters 36-59:
fun (x : 'a list) -> ();;
^^^^^^^^^^^^^^^^^^^^^^^
Error: This definition has type 'a list -> unit which is less general than
'a0. 'a0 list -> unit
This is because the 'a in (x : 'a list) is scoped at the level of the let expression, whilst the : 'a . 'a list -> unit is considered to be just inside the let expression.
This means that 'a cannot be generalized, so the definition is less general than the type constraint.
It would be nice to relax this slightly to allow what is a perfectly reasonable coding style.
The text was updated successfully, but these errors were encountered:
let foo : type a. a list -> unit =
fun (x : a list) -> ();;
The scoping works correctly here because a is locally abstract type
rather than a type variable. There are also other advantages.
(There is a drawback though, since currently we cannot use
locally abstract types for row variables. This is under consideration.)
I don't think this request should be marked as resolved. Whilst you can use a different syntax to accomplish this, the feature request is to be able to use the (more visually appealing) 'a. ... syntax.
Also, as you note, we cannot use locally abstract types with rows. Even when we are able to I suspect that it will be a bit verbose, so it would be good to be able to use 'a. ... instead.
Original bug ID: 6569
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:36:58Z)
Resolution: not a bug
Priority: normal
Severity: feature
Version: 4.02.0
Category: typing
Related to: #6673
Monitored by: @hcarty
Bug description
The following definition fails:
This is because the 'a in
(x : 'a list)
is scoped at the level of the let expression, whilst the: 'a . 'a list -> unit
is considered to be just inside the let expression.This means that 'a cannot be generalized, so the definition is less general than the type constraint.
It would be nice to relax this slightly to allow what is a perfectly reasonable coding style.
The text was updated successfully, but these errors were encountered: