From d9e7f5427740a53741dc13b58951a73dd691914d Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Tue, 31 Jul 2018 11:38:34 +0200 Subject: [PATCH] Workspace.Context.Opam: parse name to an option This makes it possible to parse it using the applicative API. Signed-off-by: Etienne Millon --- src/workspace.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/workspace.ml b/src/workspace.ml index cfbff66e..3ab86bbd 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -76,12 +76,13 @@ module Context = struct } let t ~profile ~x = - Common.t ~profile >>= fun base -> - field "switch" string >>= fun switch -> - let%map name = field "name" Name.t ~default:switch + let%map base = Common.t ~profile + and switch = field "switch" string + and name = field_o "name" Name.t and root = field_o "root" string and merlin = field_b "merlin" in + let name = Option.value ~default:switch name in let base = { base with targets = Target.add base.targets x } in { base ; switch