From 5d3f7eb6b08400547b7f0ee2b075d6b133bc90eb Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Tue, 19 Feb 2019 08:44:59 -0700 Subject: Change channel.t to use more flexible variant --- lib/models/channel/channel_t.ml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'lib/models/channel/channel_t.ml') diff --git a/lib/models/channel/channel_t.ml b/lib/models/channel/channel_t.ml index 8611d9c..0734c63 100644 --- a/lib/models/channel/channel_t.ml +++ b/lib/models/channel/channel_t.ml @@ -48,13 +48,13 @@ type category = { name: string; } [@@deriving sexp, yojson { strict = false; exn = true }] -type t = -| Group of group -| Private of dm -| GuildText of guild_text -| GuildVoice of guild_voice -| Category of category -[@@deriving sexp, yojson { strict = false; exn = true }] +type t = [ +| `Group of group +| `Private of dm +| `GuildText of guild_text +| `GuildVoice of guild_voice +| `Category of category +] [@@deriving sexp, yojson { strict = false; exn = true }] type channel_wrapper = { id: Channel_id_t.t; @@ -103,16 +103,16 @@ let unwrap_as_category {id;guild_id;position;name;_} = let wrap s = match s.kind with - | 0 -> GuildText (unwrap_as_guild_text s) - | 1 -> Private (unwrap_as_dm s) - | 2 -> GuildVoice (unwrap_as_guild_voice s) - | 3 -> Group (unwrap_as_group s) - | 4 -> Category (unwrap_as_category s) + | 0 -> `GuildText (unwrap_as_guild_text s) + | 1 -> `Private (unwrap_as_dm s) + | 2 -> `GuildVoice (unwrap_as_guild_voice s) + | 3 -> `Group (unwrap_as_group s) + | 4 -> `Category (unwrap_as_category s) | _ -> raise (Invalid_channel (channel_wrapper_to_yojson s)) -let get_id = function -| Group g -> let `Channel_id id = g.id in id -| Private p -> let `Channel_id id = p.id in id -| GuildText t -> let `Channel_id id = t.id in id -| GuildVoice v -> let `Channel_id id = v.id in id -| Category c -> let `Channel_id id = c.id in id \ No newline at end of file +let get_id (c:t) = match c with +| `Group g -> let `Channel_id id = g.id in id +| `Private p -> let `Channel_id id = p.id in id +| `GuildText t -> let `Channel_id id = t.id in id +| `GuildVoice v -> let `Channel_id id = v.id in id +| `Category c -> let `Channel_id id = c.id in id \ No newline at end of file -- cgit v1.2.3