Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005337OCamltypingpublic2011-08-15 19:222016-12-08 15:37
Reportersweeks 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version 
Summary0005337: variance not inferred for package type
DescriptionOCaml doesn't accept the following program, because it does not infer that type [t] is
covariant.

  module type S = sig
    type t
    val x : t
  end
  
  type +'a t = (module S with type t = 'a)

It would be nice if OCaml's variance inference would look inside package types.
TagsNo tags attached.
Attached Files

- Relationships
related to 0007151new Extended package type subtyping 

-  Notes
(0006090)
yminsky (reporter)
2011-08-15 19:54

Note that this also fails in 3.12.1

# module type S = sig type t val x : t end;;
module type S = sig type t val x : t end
# type +'a t = (module S with type t = 'a);;
Error: In this definition, expected parameter variances are not satisfied.
The 1st type parameter was expected to be covariant,
but it is invariant
(0006220)
garrigue (manager)
2011-12-10 04:16

Unfortunately, there is no cheap solution.
Computing the variance of a module would require going through all syntactic constructs, which probably means a huge number of lines of code.
An easy workaround is to use objects in place of first-class modules, at least when you need variance :-)
(0016726)
shinwell (developer)
2016-12-07 16:37

Jacques: is this ever going to be fixed?
(0016816)
garrigue (manager)
2016-12-08 08:52

A fix would require a breakthrough in our understanding of the interaction between modules and variance.
So I see no general fix anytime soon.
(0016829)
shinwell (developer)
2016-12-08 10:21

For things like this I wonder if we should have a "known list of limitations" to which these items can be added, rather than keeping Mantis issues open for many years. Is there anything like that (or could we start something like that?) for the type checker?

- Issue History
Date Modified Username Field Change
2011-08-15 19:22 sweeks New Issue
2011-08-15 19:54 yminsky Note Added: 0006090
2011-12-10 04:13 garrigue Assigned To => garrigue
2011-12-10 04:13 garrigue Status new => assigned
2011-12-10 04:16 garrigue Note Added: 0006220
2011-12-10 04:16 garrigue Status assigned => acknowledged
2012-07-10 13:59 doligez Severity minor => feature
2016-12-07 16:37 shinwell Note Added: 0016726
2016-12-07 16:38 shinwell Status acknowledged => assigned
2016-12-07 16:44 yallop Relationship added related to 0007151
2016-12-07 17:52 shinwell Category OCaml general => OCaml typing
2016-12-08 08:52 garrigue Note Added: 0016816
2016-12-08 10:21 shinwell Note Added: 0016829
2017-02-23 16:45 doligez Category OCaml typing => typing


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker