1

I'm seeing a declaration for what seems to be an abstract type that looks like:

 type +'a io

What does the '+' indicate there?

aneccodeal
  • 8,531
  • 7
  • 45
  • 74

1 Answers1

2

It says the type has covariant subtyping with respect to the parameter type. So if T is a subtype of U, then T io is a subtype of U io.

Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108
  • Practically speaking, what are the implications? Why would (or should) one make the declaration with the '+' as opposed to just: type 'a io ? – aneccodeal Sep 05 '14 at 23:33
  • 1
    The co-/contr-variance can't be inferred, so you have to declare it. The reason to declare it in the first place is subtle, and is explained by @gasche here: http://stackoverflow.com/questions/15561714/when-does-the-relaxed-value-restriction-kick-in-in-ocaml/15562110#15562110 – Jeffrey Scofield Sep 05 '14 at 23:36