Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005984OCamlOCaml typingpublic2013-04-12 21:262015-07-10 18:57
Assigned Togarrigue 
PlatformOSOS Version
Product Version 
Target Version4.03.0+devFixed in Version 
Summary0005984: Variance information is not properly propagated through functor applications
DescriptionType constructors that pass transparently through functors lose certain variance information along the way. For example, the following program

   module F(S : sig type 'a t end) = S

   module N : sig type +'a t end = F(struct type 'a t = 'a list end)

is rejected with this error:

   Error: Signature mismatch:
       Modules do not match:
         sig type 'a t = 'a list end
       is not included in
         sig type +'a t end
       Type declarations do not match:
         type 'a t = 'a list
       is not included in
         type +'a t
       Their variances do not agree.

However, despite this error, the type that results from the functor application is actually marked as covariant, as illustrated by the fact that the following program is accepted:

  module F(S : sig type 'a t end) = S

  module N = F(struct type 'a t = 'a list end)

  let f (x : [`A] N.t) = (x :> [`A | `B] N.t)
TagsNo tags attached.
Attached Files

- Relationships
parent of 0005985confirmedgarrigue Unexpected interaction between variance and GADTs 
Not all the children of this issue are yet resolved or closed.

-  Notes
garrigue (manager)
2013-04-13 13:39

This is well-known, long standing problems with variance and functors.
Making the variance correct would require computing it anew after
each functor application, which seemed rather heavy at the time.

Do you have a concrete example where it created problems ?

- Issue History
Date Modified Username Field Change
2013-04-12 21:26 yallop New Issue
2013-04-13 13:39 garrigue Note Added: 0009088
2013-04-13 13:39 garrigue Assigned To => garrigue
2013-04-13 13:39 garrigue Status new => confirmed
2013-04-14 19:02 gasche Relationship added child of 0005985
2013-04-14 19:03 gasche Relationship deleted child of 0005985
2013-04-14 19:03 gasche Relationship added parent of 0005985
2013-07-12 14:17 doligez Target Version => 4.02.0+dev
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2013-12-17 02:43 garrigue Relationship added related to 0006275
2013-12-17 02:47 garrigue Relationship deleted related to 0006275
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-30 14:02 doligez Target Version 4.02.0+dev => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-24 18:38 doligez Status confirmed => feedback
2014-09-24 18:38 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-01-15 00:26 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-07-10 18:57 doligez Target Version 4.02.3+dev => 4.03.0+dev

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker