Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on rresult. #306

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion odoc.opam
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ depends: [
"fpath" {build}
"ocaml" {>= "4.02.0"}
"result" {build}
"rresult" {build & >= "0.3.0"}
"tyxml" {build & >= "4.3.0"}

"alcotest" {dev & >= "0.8.3"}
Expand Down
2 changes: 1 addition & 1 deletion src/odoc/fs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module File : sig
val of_string : string -> t
val to_string : t -> string

val read : t -> (string, [> Rresult.R.msg ]) result
val read : t -> (string, [> `Msg of string ]) result

module Table : Hashtbl.S with type key = t
end
2 changes: 1 addition & 1 deletion src/parser/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
(name odoc__parser)
(public_name odoc.parser)
(preprocess (pps bisect_ppx -conditional))
(libraries astring odoc__alias odoc__compat odoc__model rresult)
(libraries astring odoc__alias odoc__compat odoc__model)
(flags (:standard -open Odoc__alias)))
20 changes: 12 additions & 8 deletions src/parser/reference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ let read_path_longident location s =
| Some r -> Result.Ok r
| None -> Result.Error (Parse_error.expected "a valid path" location)

let read_mod_longident warnings location lid : (Paths.Reference.Module.t, Error.t) Result.result =
let (>>=) = Rresult.(>>=) in

parse warnings location lid >>= function
| `Root (_, (`TUnknown | `TModule))
| `Dot (_, _)
| `Module (_, _) as r -> Result.Ok r
| _ -> Result.Error (Parse_error.expected "a reference to a module" location)
let read_mod_longident
warnings location lid : (Paths.Reference.Module.t, Error.t) Result.result
=
match parse warnings location lid with
| Error _ as e -> e
| Ok p ->
match p with
| `Root (_, (`TUnknown | `TModule))
| `Dot (_, _)
| `Module (_, _) as r -> Result.Ok r
| _ ->
Result.Error (Parse_error.expected "a reference to a module" location)
15 changes: 8 additions & 7 deletions src/parser/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,14 @@ let rec block_element_list
cooperation to get the real location. *)
let r_location =
Location.nudge_start (String.length "@canonical ") location in

let (>>=) = Rresult.(>>=) in
let result =
Reference.read_path_longident r_location s >>= fun path ->
Reference.read_mod_longident
input.warnings r_location s >>= fun module_ ->
Result.Ok (`Canonical (path, module_))
let result = match Reference.read_path_longident r_location s with
| Error _ as e -> e
| Ok path ->
match
Reference.read_mod_longident input.warnings r_location s
with
| Error _ as e -> e
| Ok module_ -> Result.Ok (`Canonical (path, module_))
in
match result with
| Result.Ok _ as result -> result
Expand Down