aboutsummaryrefslogtreecommitdiff
path: root/lib/client.ml
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2018-11-29 12:55:10 -0700
committerAdelyn Breelove <[email protected]>2018-11-29 12:55:10 -0700
commit473072f66e6c7e228b4f26730cbc7304941fb12b (patch)
treecd689e7f53bafbf357c8be88e317251b2a4b7539 /lib/client.ml
parentClean up a bit (diff)
downloaddisml-473072f66e6c7e228b4f26730cbc7304941fb12b.tar.xz
disml-473072f66e6c7e228b4f26730cbc7304941fb12b.zip
functors!
Diffstat (limited to 'lib/client.ml')
-rw-r--r--lib/client.ml61
1 files changed, 34 insertions, 27 deletions
diff --git a/lib/client.ml b/lib/client.ml
index e88b1d5..7adaae3 100644
--- a/lib/client.ml
+++ b/lib/client.ml
@@ -1,35 +1,42 @@
open Async
-type t = {
- sharder: Sharder.t Ivar.t;
- handler: string Pipe.Writer.t;
- token: string;
-}
+module Make(T : S.Token) = struct
+ include T
+
+ module Http = Http.Make(T)
+ module Sharder = Sharder.Make(Http)
-let create ~handler token =
- {
- sharder = Ivar.create ();
- handler;
- token;
+ type t = {
+ sharder: Sharder.t Ivar.t;
+ handler: string Pipe.Writer.t;
+ token: string;
}
-let start ?count client =
- Sharder.start ?count client.token
- >>| fun sharder ->
- Ivar.fill_if_empty client.sharder sharder;
- client
+ let init ~handler () =
+ {
+ sharder = Ivar.create ();
+ handler;
+ token;
+ }
-let set_status ~status client =
- Ivar.read client.sharder
- >>= fun sharder ->
- Sharder.set_status sharder status
+ let start ?count client =
+ Sharder.start ?count client.token
+ >>| fun sharder ->
+ Ivar.fill_if_empty client.sharder sharder;
+ client
-let set_status_with ~f client =
- Ivar.read client.sharder
- >>= fun sharder ->
- Sharder.set_status_with sharder f
+ let set_status ~status client =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.set_status sharder status
-let request_guild_members ~guild ?query ?limit client =
- Ivar.read client.sharder
- >>= fun sharder ->
- Sharder.request_guild_members ~guild ?query ?limit sharder
+ let set_status_with ~f client =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.set_status_with sharder f
+
+ let request_guild_members ~guild ?query ?limit client =
+ Ivar.read client.sharder
+ >>= fun sharder ->
+ Sharder.request_guild_members ~guild ?query ?limit sharder
+end \ No newline at end of file