ocamllabs / ocaml-modular-implicits

OCaml extended with modular implicits
Other
103 stars 8 forks source link

Implicit search in presence of polymorphic variants #27

Open LeoTestard opened 9 years ago

LeoTestard commented 9 years ago

The following code doesn't compile

module type Foo = sig
    type 'a t
    val f : 'a t -> int
end

implicit module Foo1 = struct
    type 'a t = unit
    let f () = 0
end

implicit module Foo2 = struct
    type 'a t = [> `Foo | `Bar ] as 'a
    let f (_: 'a t) = 0
end

let f (implicit M: Foo) x = M.f x

let () =
    f `Foo ;
    ()

cc @def-lkb

yallop commented 9 years ago

This looks like expected behaviour. The code doesn't compile because the module Foo2 doesn't match the module type Foo.