Skip to content

Instantly share code, notes, and snippets.

/connection.ml Secret

Created June 3, 2017 16:42
Show Gist options
  • Save anonymous/93e86d5c60b277729cfa6227e37c055a to your computer and use it in GitHub Desktop.
Save anonymous/93e86d5c60b277729cfa6227e37c055a to your computer and use it in GitHub Desktop.
module Connection =
struct
type connecting = {
when_initialized: int;}
type connected = {
session_id: string;}
type disconnected = {
when_disconnected: int;}
type state =
| Connecting of connecting
| Connected of connected
| Disconnected of disconnected
type t = {
state: state;
host: string;}
end
module App =
struct
open Connection
let connection =
{
state = ((Connected ({ session_id = "ABC" }))[@explicit_arity ]);
host = "localhost"
}
let _ = print_endline connection.host
let _ =
print_endline
(match connection.state with
| ((Connected (p))[@explicit_arity ]) -> p.session_id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment