Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005337OCamlOCaml generalpublic2011-08-15 19:222012-07-10 13:59
Reportersweeks 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
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

-  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 :-)

- 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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker