Ocaml destructive substitution error

Viewed 356
type ('a, 'r) loop
type 'e task
type ('a, 'e) tmpl'

module type COMPONENT =
sig
    type t
    type event
    type r

    val update : t -> event -> r
    val view : (t, event) tmpl'
end

module type MAIN_COMPONENT =
sig
    type t
    type event
    type r

    include COMPONENT
        with type t := t
        with type event := event
        with type r := (t * event task option, r) loop
end

I'm getting this error while trying to substitute the type r:

Error: Only type constructors with identical parameters can be substituted.

However, this works:

module type MAIN_COMPONENT =
sig
    type t
    type event
    type r
    type r' = (t * event task option, r) loop

    include COMPONENT
        with type t := t
        with type event := event
        with type r := r'
end

Why ?

How can i get rid of the r' type ?

1 Answers
Related