Workspace.Context.Opam: parse name to an option

This makes it possible to parse it using the applicative API.

Signed-off-by: Etienne Millon <me@emillon.org>
This commit is contained in:
Etienne Millon 2018-07-31 11:38:34 +02:00 committed by Etienne Millon
parent 282c0b3c41
commit d9e7f54277
1 changed files with 4 additions and 3 deletions

View File

@ -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