Immediately Opened Functors - why aren't they possible?


I was playing with monads, and I was curious - why can’t we open functor module expressions? Why do we have to give them a name, or include them? Is there anything preventing us from doing this?

Code I was playing with:

module type Type  = sig type t end

module type Monad  =
    type 'a t
    val pure : 'a -> 'a t
    val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

module Monad_result(T: Type) : Monad =
    type 'o t = ('o, T.t) result
    let pure x = Ok x
    let (>>=) res f =
      match res with
      | Ok o -> f o
      | Err e -> Err e

(* what I have to write *)
module M = Monad_result(struct type t = int end)
open M
(* what I'd like to write *)
open Monad_result(struct type t = int end)




Indeed it would be great!

Jeremy Yallop and Runhang Li presented a proposal at the OCaml Workshop 2017.
Here are the paper and the pull request: