Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005984OCamlOCaml typingpublic2013-04-12 21:262016-08-16 04:08
Reporteryallop 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target Version4.03.0+dev / +beta1Fixed 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 
parent of 0007321confirmedgarrigue Private type in signature clashes with type definition via functor instantiation 
related to 0007212acknowledged Covariance propagation across functors 
related to 0000299closed module typing bug? 
Not all the children of this issue are yet resolved or closed.

-  Notes
(0009088)
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 ?
(0014798)
xleroy (administrator)
2015-11-23 15:31

I interpret the absence of discussion in the last two years as a "won't fix" decision. Correct?
(0014799)
yallop (developer)
2015-11-23 15:33

This isn't causing problems for me in practice, so I'm happy for it to be closed.
(0014806)
xleroy (administrator)
2015-11-23 15:53

Thanks, Jeremy. Marking as "won't fix".
(0014814)
garrigue (manager)
2015-11-24 00:46

Just for the record: this is not a definitive "won't fix".
I put it in the same category as allowing refinement in non-local abstract types.
I.e. something that the language should do, but that is not easy with the current implementation.

- 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 / +beta1
2015-11-23 15:31 xleroy Note Added: 0014798
2015-11-23 15:33 yallop Note Added: 0014799
2015-11-23 15:33 yallop Status feedback => assigned
2015-11-23 15:53 xleroy Note Added: 0014806
2015-11-23 15:53 xleroy Status assigned => resolved
2015-11-23 15:53 xleroy Resolution open => won't fix
2015-11-24 00:46 garrigue Note Added: 0014814
2016-04-05 16:19 doligez Relationship added related to 0007212
2016-08-16 04:02 garrigue Relationship added parent of 0007321
2016-08-16 04:08 garrigue Relationship added related to 0000299


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker