Skip to content

More relaxed scoping of type variables and polymorphic type annotations #6569

@vicuna

Description

@vicuna

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions