I’m curious if it’s possible to write a module signature similar to the following:
module type Foo = sig type a type b val expand : [ a | b ] list -> a list end
Basically each module that wants to fulfill
Foo must provide two polymorphic variant types
b and a function that takes a list of variants from either type and expands all variants from type
b into variants from type
a. My version doesn’t work because neither type can expand into a polymorphic variant (since
b could be anything, e.g.
int). Is there any way to annotate
b to ensure they are polymorphic variant types?
Currently I’m working around the problem by instead requiring a function
val expand : b -> a list and calling that function and flatmapping the result in the functor that uses