{"action":"created","issue":{"url":"https://api.github.com/repos/xyncro/chiron/issues/37","labels_url":"https://api.github.com/repos/xyncro/chiron/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/xyncro/chiron/issues/37/comments","events_url":"https://api.github.com/repos/xyncro/chiron/issues/37/events","html_url":"https://github.com/xyncro/chiron/issues/37","id":79862041,"number":37,"title":"Q: better way to write?","user":{"login":"haf","id":193115,"avatar_url":"https://avatars.githubusercontent.com/u/193115?v=3","gravatar_id":"","url":"https://api.github.com/users/haf","html_url":"https://github.com/haf","followers_url":"https://api.github.com/users/haf/followers","following_url":"https://api.github.com/users/haf/following{/other_user}","gists_url":"https://api.github.com/users/haf/gists{/gist_id}","starred_url":"https://api.github.com/users/haf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haf/subscriptions","organizations_url":"https://api.github.com/users/haf/orgs","repos_url":"https://api.github.com/users/haf/repos","events_url":"https://api.github.com/users/haf/events{/privacy}","received_events_url":"https://api.github.com/users/haf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-23T14:30:31Z","updated_at":"2015-07-04T21:16:44Z","closed_at":null,"body":"I've been trying to find a better way to write this with the current API, but can't think of it at the moment:\r\n\r\n``` fsharp\r\n  let writeJsonBody : SessionOptions -> Json<unit> =\r\n    List.fold (fun acc -> function\r\n              | LockDelay dur -> acc *> Json.write \"LockDelay\" (Duration.consulString dur)\r\n              | Node node     -> acc *> Json.write \"Node\" node\r\n              | Name name     -> acc *> Json.write \"Name\" name\r\n              | Checks checks -> acc *> Json.write \"Checks\" checks\r\n              | Behaviour sb  -> acc *> Json.write \"Behavior\" sb\r\n              | TTL dur       -> acc *> Json.write \"TTL\" (Duration.consulString dur))\r\n              (fun json -> Value (), Json.Object Map.empty)\r\n\r\n  let reqBody = Json.format (snd (writeJsonBody sessionOpts (Json.Null ())))\r\n```\r\n\r\nI'm mostly thinking how the last two lines with contents both declare Json data and how I have to use `snd` to get the Json result of the monad value."},"comment":{"url":"https://api.github.com/repos/xyncro/chiron/issues/comments/118556005","html_url":"https://github.com/xyncro/chiron/issues/37#issuecomment-118556005","issue_url":"https://api.github.com/repos/xyncro/chiron/issues/37","id":118556005,"user":{"login":"kolektiv","id":1546,"avatar_url":"https://avatars.githubusercontent.com/u/1546?v=3","gravatar_id":"","url":"https://api.github.com/users/kolektiv","html_url":"https://github.com/kolektiv","followers_url":"https://api.github.com/users/kolektiv/followers","following_url":"https://api.github.com/users/kolektiv/following{/other_user}","gists_url":"https://api.github.com/users/kolektiv/gists{/gist_id}","starred_url":"https://api.github.com/users/kolektiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolektiv/subscriptions","organizations_url":"https://api.github.com/users/kolektiv/orgs","repos_url":"https://api.github.com/users/kolektiv/repos","events_url":"https://api.github.com/users/kolektiv/events{/privacy}","received_events_url":"https://api.github.com/users/kolektiv/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T21:16:44Z","updated_at":"2015-07-04T21:16:44Z","body":"Pong! Right, brain back in F# :) I'm not sure I can think of an obviously nicer way at the moment, but I'm not totally sure what SessionOptions looks like. Can you point me to the wider source, and I'll have a further think!"}}