Last active
March 24, 2019 15:44
-
-
Save Pitometsu/5e79f7cb077da03184170815fb6b7f5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type Subscriber = sig | |
module Message : sig | |
type t = .. | |
end | |
type msgs | |
val filter_message : msgs -> Message.t option | |
val callback : Message.t -> msgs list | |
end | |
module type Bus = sig | |
include Subscriber | |
val components : (module Subscriber) list | |
end | |
module Add (A : Subscriber) (B : Subscriber) : Bus with module Message = (struct (* Error: syntax error *) | |
type t = .. | |
type t += A.Message.t | |
type t += B.Message.t | |
end) = | |
struct | |
let components = (module A) :: [ (module B) ] | |
let filter_message = ident | |
let callback msg = A.callback (A.filter_message msg) @ B.callback (B.filter_message msg) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment