-
-
Save raphael-proust/886559 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
ocamlc x.ml | |
File "x.ml", line 30, characters 16-28: | |
Error: Unbound value Rep.dispatch |
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 Message = | |
sig | |
type obj | |
type variant | |
val make : unit -> obj | |
(* encapsulate object in a variant type *) | |
val convert : obj -> variant | |
val print : obj -> unit | |
end | |
module type Request = | |
sig | |
include Message | |
end | |
(* dispatches based on a request *) | |
module type Reply = functor (Req : Request) -> | |
sig | |
include Message | |
val dispatch : Req.variant -> obj | |
end | |
module Server (Req : Request) (Rep : Reply) = | |
struct | |
let server = | |
while true do | |
let req = Req.make () in | |
let var = Req.convert req in | |
let rep = Rep.dispatch var in | |
Req.dump req; | |
Rep.dump rep | |
done | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment