this repo has no description

Remove dependency on the 'result' package

This package is no longer needed since our lower-bound is 4.08.
The Result prefix in Result.result and Result.Ok can be removed to make
the code nicer.

authored by

Jules Aguillon and committed by jon.recoil.org 8478ff40 a4a72ec9

+133 -172
-1
odoc-parser.opam
··· 17 17 "dune" {>= "3.7"} 18 18 "ocaml" {>= "4.08.0" & < "5.4"} 19 19 "astring" 20 - "result" 21 20 "camlp-streams" 22 21 "ppx_expect" {with-test} 23 22 "sexplib0" {with-test}
-1
odoc.opam
··· 47 47 "dune" {>= "3.7.0"} 48 48 "fpath" 49 49 "ocaml" {>= "4.08.0" & < "5.4"} 50 - "result" 51 50 "tyxml" {>= "4.4.0"} 52 51 "fmt" 53 52 "crunch" {>= "1.4.1"}
+1 -1
src/document/utils.ml
··· 1 - let option_of_result = function Result.Ok x -> Some x | Result.Error _ -> None 1 + let option_of_result = function Ok x -> Some x | Error _ -> None 2 2 3 3 let rec flatmap ?sep ~f = function 4 4 | [] -> []
+1 -1
src/document/utils.mli
··· 1 - val option_of_result : ('a, 'b) Result.result -> 'a option 1 + val option_of_result : ('a, 'b) result -> 'a option 2 2 val flatmap : ?sep:'a list -> f:('b -> 'a list) -> 'b list -> 'a list 3 3 val skip_until : p:('a -> bool) -> 'a list -> 'a list 4 4 val split_at : f:('a -> bool) -> 'a list -> 'a list * 'a list
-1
src/loader/odoc_loader.mli
··· 1 - open Result 2 1 open Odoc_model 3 2 open Odoc_model.Paths 4 3
+1 -1
src/model/dune
··· 16 16 (backend landmarks --auto)) 17 17 (instrumentation 18 18 (backend bisect_ppx)) 19 - (libraries result compiler-libs.common odoc-parser odoc_utils)) 19 + (libraries compiler-libs.common odoc-parser odoc_utils))
+1 -3
src/model/error.ml
··· 1 - open Result 2 - 3 1 let enable_missing_root_warning = ref false 4 2 5 3 type full_location_payload = Odoc_parser.Warning.t = { ··· 90 88 let warnings = List.rev !raised_warnings in 91 89 { value; warnings }) 92 90 93 - type 'a with_errors_and_warnings = ('a, t) Result.result with_warnings 91 + type 'a with_errors_and_warnings = ('a, t) result with_warnings 94 92 95 93 let raise_errors_and_warnings we = 96 94 match raise_warnings we with Ok x -> x | Error e -> raise_exception e
+4 -4
src/model/error.mli
··· 16 16 (** Raise a {!t} as an exception. Can be caught with {!catch} or 17 17 {!catch_errors_and_warnings}. *) 18 18 19 - val catch : (unit -> 'a) -> ('a, t) Result.result 19 + val catch : (unit -> 'a) -> ('a, t) result 20 20 21 21 type 'a with_warnings 22 22 ··· 30 30 val catch_warnings : (unit -> 'a) -> 'a with_warnings 31 31 (** Catch warnings accumulated by [raise_warning]. Safe to nest. *) 32 32 33 - type 'a with_errors_and_warnings = ('a, t) Result.result with_warnings 33 + type 'a with_errors_and_warnings = ('a, t) result with_warnings 34 34 (** Subtype of [with_warnings]. *) 35 35 36 36 val raise_errors_and_warnings : 'a with_errors_and_warnings -> 'a ··· 48 48 val handle_warnings : 49 49 warnings_options:warnings_options -> 50 50 'a with_warnings -> 51 - ('a, [> `Msg of string ]) Result.result 51 + ('a, [> `Msg of string ]) result 52 52 (** Print warnings to stderr. If [warn_error] is [true] and there was warnings, 53 53 returns an [Error]. *) 54 54 55 55 val handle_errors_and_warnings : 56 56 warnings_options:warnings_options -> 57 57 'a with_errors_and_warnings -> 58 - ('a, [> `Msg of string ]) Result.result 58 + ('a, [> `Msg of string ]) result 59 59 (** Like [handle_warnings] but works on the output of 60 60 [catch_errors_and_warnings]. Error case is converted into a [`Msg]. *) 61 61
+5 -5
src/model/frontmatter.ml
··· 74 74 let parse_children_order loc (co : tag_payload) = 75 75 let rec parse_words acc words = 76 76 match words with 77 - | [] -> Result.Ok (Location_.at loc (Children_order (List.rev acc))) 77 + | [] -> Ok (Location_.at loc (Children_order (List.rev acc))) 78 78 | ({ Location_.value = `Word word; _ } as w) :: tl -> 79 79 parse_words ({ w with value = parse_child word } :: acc) tl 80 80 | { Location_.value = `Space; _ } :: tl -> parse_words acc tl ··· 93 93 match t with 94 94 | [ { Location_.value = `Paragraph words; _ } ] -> 95 95 let short_title = Comment.link_content_of_inline_elements words in 96 - Result.Ok (Location_.at loc (Short_title short_title)) 96 + Ok (Location_.at loc (Short_title short_title)) 97 97 | _ -> 98 98 Error 99 99 (Error.make ··· 104 104 | [ 105 105 { Location_.value = `Paragraph [ { Location_.value = `Word "open"; _ } ]; _ }; 106 106 ] -> 107 - Result.Ok (Location_.at loc (Toc_status `Open)) 107 + Ok (Location_.at loc (Toc_status `Open)) 108 108 | [ 109 109 { 110 110 Location_.value = `Paragraph [ { Location_.value = `Word "hidden"; _ } ]; 111 111 _; 112 112 }; 113 113 ] -> 114 - Result.Ok (Location_.at loc (Toc_status `Hidden)) 114 + Ok (Location_.at loc (Toc_status `Hidden)) 115 115 | _ -> 116 116 Error 117 117 (Error.make "@toc_status can only take the 'open' and 'hidden' value" ··· 121 121 match t with 122 122 | [ { Location_.value = `Paragraph [ { Location_.value = `Word w; _ } ]; _ } ] 123 123 -> 124 - Result.Ok (Location_.at loc (Order_category w)) 124 + Ok (Location_.at loc (Order_category w)) 125 125 | _ -> 126 126 Error 127 127 (Error.make "@order_category can only take a single word as value" loc)
+4 -4
src/model/frontmatter.mli
··· 20 20 val parse_children_order : 21 21 Location_.span -> 22 22 tag_payload -> 23 - (line Location_.with_location, Error.t) Result.result 23 + (line Location_.with_location, Error.t) result 24 24 25 25 val parse_short_title : 26 26 Location_.span -> 27 27 tag_payload -> 28 - (line Location_.with_location, Error.t) Result.result 28 + (line Location_.with_location, Error.t) result 29 29 30 30 val parse_toc_status : 31 31 Location_.span -> 32 32 tag_payload -> 33 - (line Location_.with_location, Error.t) Result.result 33 + (line Location_.with_location, Error.t) result 34 34 35 35 val parse_order_category : 36 36 Location_.span -> 37 37 tag_payload -> 38 - (line Location_.with_location, Error.t) Result.result 38 + (line Location_.with_location, Error.t) result 39 39 40 40 val of_lines : line Location_.with_location list -> t Error.with_warnings
+4 -6
src/model/reference.ml
··· 590 590 in 591 591 Error.catch_warnings (fun () -> 592 592 match loop s (String.length s - 1) with 593 - | Some r -> Result.Ok (r :> path) 594 - | None -> Result.Error (expected_err_str "a valid path" location)) 593 + | Some r -> Ok (r :> path) 594 + | None -> Error (expected_err_str "a valid path" location)) 595 595 596 596 let read_mod_longident location lid = 597 597 Error.catch_warnings (fun () -> ··· 601 601 match p with 602 602 | (`Root (_, (`TUnknown | `TModule)) | `Dot (_, _) | `Module (_, _)) 603 603 as r -> 604 - Result.Ok r 605 - | _ -> 606 - Result.Error (expected_err_str "a reference to a module" location) 607 - )) 604 + Ok r 605 + | _ -> Error (expected_err_str "a reference to a module" location)))
+14 -14
src/model/semantics.ml
··· 192 192 | { value = `Reference (kind, target, content) as value; location } -> ( 193 193 let { Location.value = target; location = target_location } = target in 194 194 match Error.raise_warnings (Reference.parse target_location target) with 195 - | Result.Ok target -> 195 + | Ok target -> 196 196 let content = non_link_inline_elements ~surrounding:value content in 197 197 Location.at location (`Reference (target, content)) 198 - | Result.Error error -> 198 + | Error error -> 199 199 Error.raise_warning error; 200 200 let placeholder = 201 201 match kind with ··· 248 248 match 249 249 Error.raise_warnings (Reference.read_mod_longident location value) 250 250 with 251 - | Result.Ok r -> 251 + | Ok r -> 252 252 { Comment.module_reference = r; module_synopsis = None } :: acc 253 - | Result.Error error -> 253 + | Error error -> 254 254 Error.raise_warning error; 255 255 acc) 256 256 [] modules ··· 288 288 |> Location.at location 289 289 in 290 290 match Error.raise_warnings (Reference.parse_asset href_location href) with 291 - | Result.Ok target -> 291 + | Ok target -> 292 292 `Media (`Reference target, m, content) |> Location.at location 293 - | Result.Error error -> fallback error) 293 + | Error error -> fallback error) 294 294 295 295 and nestable_block_elements elements = List.map nestable_block_element elements 296 296 ··· 300 300 Ast.ocamldoc_tag -> 301 301 ( Comment.block_element with_location, 302 302 internal_tags_removed with_location ) 303 - Result.result = 303 + result = 304 304 fun ~location status tag -> 305 305 if not status.tags_allowed then 306 306 (* Trigger a warning but do not remove the tag. Avoid turning tags into 307 307 text that would render the same. *) 308 308 Error.raise_warning (tags_not_allowed location); 309 - let ok t = Result.Ok (Location.at location (`Tag t)) in 309 + let ok t = Ok (Location.at location (`Tag t)) in 310 310 match tag with 311 311 | (`Author _ | `Since _ | `Version _) as tag -> ok tag 312 312 | `Deprecated content -> ok (`Deprecated (nestable_block_elements content)) ··· 315 315 | `Raise (name, content) -> ( 316 316 match Error.raise_warnings (Reference.parse location name) with 317 317 (* TODO: location for just name *) 318 - | Result.Ok target -> 318 + | Ok target -> 319 319 ok (`Raise (`Reference (target, []), nestable_block_elements content)) 320 - | Result.Error error -> 320 + | Error error -> 321 321 Error.raise_warning error; 322 322 let placeholder = `Code_span name in 323 323 ok (`Raise (placeholder, nestable_block_elements content))) ··· 465 465 ast_elements 466 466 | { value = `Tag the_tag; location } -> ( 467 467 match tag ~location status the_tag with 468 - | Result.Ok element -> 468 + | Ok element -> 469 469 traverse ~top_heading_level 470 470 (element :: comment_elements_acc) 471 471 ast_elements 472 - | Result.Error placeholder -> 472 + | Error placeholder -> 473 473 traverse ~top_heading_level comment_elements_acc 474 474 (placeholder :: ast_elements)) 475 475 | { value = `Heading _ as heading; _ } -> ··· 510 510 match 511 511 Error.raise_warnings (Reference.read_path_longident r_location s) 512 512 with 513 - | Result.Ok path -> next (`Canonical path) 514 - | Result.Error e -> 513 + | Ok path -> next (`Canonical path) 514 + | Error e -> 515 515 Error.raise_warning e; 516 516 loop ~start tags ast' tl)) 517 517 | ({
+5 -5
src/odoc/bin/main.ml
··· 37 37 let convert_fpath = 38 38 let parse inp = 39 39 match Arg.(conv_parser file) inp with 40 - | Ok s -> Result.Ok (Fs.File.of_string s) 40 + | Ok s -> Ok (Fs.File.of_string s) 41 41 | Error _ as e -> e 42 42 and print = Fpath.pp in 43 43 Arg.conv (parse, print) ··· 45 45 let convert_named_root = 46 46 let parse inp = 47 47 match String.cuts inp ~sep:":" with 48 - | [ s1; s2 ] -> Result.Ok (s1, Fs.Directory.of_string s2) 48 + | [ s1; s2 ] -> Ok (s1, Fs.Directory.of_string s2) 49 49 | _ -> Error (`Msg "") 50 50 in 51 51 let print ppf (s, t) = ··· 54 54 Arg.conv (parse, print) 55 55 56 56 let handle_error = function 57 - | Result.Ok () -> () 57 + | Ok () -> () 58 58 | Error (`Cli_error msg) -> 59 59 Printf.eprintf "%s\n%!" msg; 60 60 exit 2 ··· 86 86 rest 87 87 && check rest 88 88 in 89 - if check l then Result.Ok () 89 + if check l then Ok () 90 90 else 91 91 let msg = 92 92 Format.sprintf "Paths given to all %s options must be disjoint" opt ··· 1273 1273 let convert_remap = 1274 1274 let parse inp = 1275 1275 match String.cut ~sep:":" inp with 1276 - | Some (orig, mapped) -> Result.Ok (orig, mapped) 1276 + | Some (orig, mapped) -> Ok (orig, mapped) 1277 1277 | _ -> Error (`Msg "Map must be of the form '<orig>:https://...'") 1278 1278 and print fmt (orig, mapped) = Format.fprintf fmt "%s:%s" orig mapped in 1279 1279 Arg.conv (parse, print)
+16 -17
src/odoc/fs.ml
··· 51 51 52 52 let create ~directory ~name = 53 53 match Fpath.of_string name with 54 - | Result.Error (`Msg e) -> invalid_arg ("Odoc.Fs.File.create: " ^ e) 55 - | Result.Ok psuf -> Fpath.(normalize @@ (directory // psuf)) 54 + | Error (`Msg e) -> invalid_arg ("Odoc.Fs.File.create: " ^ e) 55 + | Ok psuf -> Fpath.(normalize @@ (directory // psuf)) 56 56 57 57 let to_string = Fpath.to_string 58 58 let segs = Fpath.segs 59 59 60 60 let of_string s = 61 61 match Fpath.of_string s with 62 - | Result.Error (`Msg e) -> invalid_arg ("Odoc.Fs.File.of_string: " ^ e) 63 - | Result.Ok p -> p 62 + | Error (`Msg e) -> invalid_arg ("Odoc.Fs.File.of_string: " ^ e) 63 + | Ok p -> p 64 64 65 65 let read file = 66 66 let input_one_shot len ic = 67 67 let buf = Bytes.create len in 68 68 really_input ic buf 0 len; 69 69 close_in ic; 70 - Result.Ok (Bytes.unsafe_to_string buf) 70 + Ok (Bytes.unsafe_to_string buf) 71 71 in 72 72 let input_stream file ic = 73 73 let bsize = ··· 78 78 let rec loop () = 79 79 match Buffer.add_channel buf ic bsize with 80 80 | () -> loop () 81 - | exception End_of_file -> Result.Ok (Buffer.contents buf) 81 + | exception End_of_file -> Ok (Buffer.contents buf) 82 82 | exception Failure _ -> 83 - Result.Error (`Msg (Printf.sprintf "%s: input too large" file)) 83 + Error (`Msg (Printf.sprintf "%s: input too large" file)) 84 84 in 85 85 loop () 86 86 in ··· 95 95 | len when len <= Sys.max_string_length -> input_one_shot len ic 96 96 | len -> 97 97 let err = Printf.sprintf "%s: file too large (%d bytes)" file len in 98 - Result.Error (`Msg err) 99 - with Sys_error e -> Result.Error (`Msg e) 98 + Error (`Msg err) 99 + with Sys_error e -> Error (`Msg e) 100 100 101 101 let copy ~src ~dst = 102 102 try ··· 112 112 loop ()) 113 113 in 114 114 Ok (loop ()))) 115 - with Sys_error e -> Result.Error (`Msg e) 115 + with Sys_error e -> Error (`Msg e) 116 116 117 117 let exists file = Sys.file_exists (Fpath.to_string file) 118 118 ··· 147 147 148 148 let make_path p name = 149 149 match Fpath.of_string name with 150 - | Result.Error _ as e -> e 151 - | Result.Ok psuf -> 152 - Result.Ok Fpath.(normalize @@ to_dir_path @@ (p // psuf)) 150 + | Error _ as e -> e 151 + | Ok psuf -> Ok Fpath.(normalize @@ to_dir_path @@ (p // psuf)) 153 152 154 153 let reach_from ~dir path = 155 154 match make_path dir path with 156 - | Result.Error (`Msg e) -> invalid_arg ("Odoc.Fs.Directory.create: " ^ e) 157 - | Result.Ok path -> 155 + | Error (`Msg e) -> invalid_arg ("Odoc.Fs.Directory.create: " ^ e) 156 + | Ok path -> 158 157 let pstr = Fpath.to_string path in 159 158 if Sys.file_exists pstr && not (Sys.is_directory pstr) then 160 159 invalid_arg "Odoc.Fs.Directory.create: not a directory"; ··· 172 171 173 172 let of_string s = 174 173 match Fpath.of_string s with 175 - | Result.Error (`Msg e) -> invalid_arg ("Odoc.Fs.Directory.of_string: " ^ e) 176 - | Result.Ok p -> Fpath.to_dir_path p 174 + | Error (`Msg e) -> invalid_arg ("Odoc.Fs.Directory.of_string: " ^ e) 175 + | Ok p -> Fpath.to_dir_path p 177 176 178 177 let of_file f = Fpath.to_dir_path f 179 178
+1 -3
src/odoc/or_error.ml
··· 1 - type ('a, 'e) result = ('a, 'e) Result.result = Ok of 'a | Error of 'e 2 - 3 1 type msg = [ `Msg of string ] 4 2 5 - let ( >>= ) r f = match r with Ok v -> f v | Error _ as e -> e 3 + let ( >>= ) = Result.bind 6 4 7 5 let rec fold_list f acc = function 8 6 | [] -> Ok acc
-3
src/odoc/or_error.mli
··· 1 - (** Re-export for compatibility with 4.02 *) 2 - type ('a, 'e) result = ('a, 'e) Result.result = Ok of 'a | Error of 'e 3 - 4 1 type msg = [ `Msg of string ] 5 2 6 3 val ( >>= ) : ('a, 'e) result -> ('a -> ('b, 'e) result) -> ('b, 'e) result
+1 -1
src/parser/dune
··· 9 9 (backend bisect_ppx)) 10 10 (flags 11 11 (:standard -w -50)) 12 - (libraries astring result camlp-streams)) 12 + (libraries astring camlp-streams))
+1 -1
src/utils/dune
··· 1 1 (library 2 2 (name odoc_utils) 3 3 (public_name odoc.odoc_utils) 4 - (libraries result astring)) 4 + (libraries astring))
+2 -7
src/utils/odoc_utils.ml
··· 1 1 (** The [result] type and a bind operator. This module is meant to be opened. *) 2 2 module ResultMonad = struct 3 - (** Re-export for compat *) 4 - type ('a, 'b) result = ('a, 'b) Result.result = Ok of 'a | Error of 'b 5 - 6 3 let map_error f = function Ok _ as ok -> ok | Error e -> Error (f e) 7 4 8 5 let of_option ~error = function Some x -> Ok x | None -> Error error 9 6 10 - let bind m f = match m with Ok x -> f x | Error _ as e -> e 11 - 12 - let ( >>= ) = bind 7 + let ( >>= ) = Result.bind 13 8 end 14 9 15 10 (** A bind operator for the [option] type. This module is meant to be opened. *) 16 11 module OptionMonad = struct 17 12 (* The error case become [None], the error value is ignored. *) 18 - let of_result = function Result.Ok x -> Some x | Error _ -> None 13 + let of_result = function Ok x -> Some x | Error _ -> None 19 14 20 15 let ( >>= ) = Option.bind 21 16 end
+3 -5
src/xref2/env.ml
··· 479 479 root : string -> t -> 'a option; 480 480 } 481 481 482 - type 'a maybe_ambiguous = ('a, [ 'a amb_err | `Not_found ]) Result.result 482 + type 'a maybe_ambiguous = ('a, [ 'a amb_err | `Not_found ]) result 483 483 484 484 let make_scope ?(root = fun _ _ -> None) ?check 485 485 (filter : _ -> ([< Component.Element.any ] as 'a) option) : 'a scope = ··· 503 503 with 504 504 | ([ x ] as results), Some c -> ( 505 505 record_lookup_results env results; 506 - match c env x with 507 - | Some (`Ambiguous _ as e) -> Result.Error e 508 - | None -> Result.Ok x) 506 + match c env x with Some (`Ambiguous _ as e) -> Error e | None -> Ok x) 509 507 | ([ x ] as results), None -> 510 508 record_lookup_results env results; 511 - Result.Ok x 509 + Ok x 512 510 | (x :: tl as results), _ -> 513 511 record_lookup_results env results; 514 512 Error (`Ambiguous (x, tl))
+1 -1
src/xref2/env.mli
··· 115 115 (** Target of a lookup *) 116 116 117 117 type 'a maybe_ambiguous = 118 - ('a, [ `Ambiguous of 'a * 'a list | `Not_found ]) Result.result 118 + ('a, [ `Ambiguous of 'a * 'a list | `Not_found ]) result 119 119 120 120 val lookup_by_name : 'a scope -> string -> t -> 'a maybe_ambiguous 121 121 (** Lookup an element in Env depending on the given [scope]. Return
+1 -1
src/xref2/expand_tools.ml
··· 25 25 (env', Subst.module_type_expr subst expr) 26 26 in 27 27 let rec expand id env expansion : 28 - (Env.t * Component.ModuleType.simple_expansion, _) Result.result = 28 + (Env.t * Component.ModuleType.simple_expansion, _) result = 29 29 match expansion with 30 30 | Tools.Signature sg -> 31 31 Ok
+1 -1
src/xref2/link.ml
··· 761 761 List.fold_left 762 762 (fun (sg_res, subs) lsub -> 763 763 match (sg_res, lsub) with 764 - | Result.Ok sg, ModuleEq (frag, decl) -> 764 + | Ok sg, ModuleEq (frag, decl) -> 765 765 let frag' = 766 766 match frag with 767 767 | `Resolved f ->
+1 -2
src/xref2/ref_tools.ml
··· 39 39 type fragment_type_parent_lookup_result = 40 40 [ `S of signature_lookup_result | `T of datatype_lookup_result ] 41 41 42 - type 'a ref_result = 43 - ('a, Errors.Tools_error.reference_lookup_error) Result.result 42 + type 'a ref_result = ('a, Errors.Tools_error.reference_lookup_error) result 44 43 (** The result type for every functions in this module. *) 45 44 46 45 let kind_of_find_result = function
+1 -2
src/xref2/ref_tools.mli
··· 5 5 6 6 type asset_lookup_result = Resolved.Asset.t 7 7 8 - type 'a ref_result = 9 - ('a, Errors.Tools_error.reference_lookup_error) Result.result 8 + type 'a ref_result = ('a, Errors.Tools_error.reference_lookup_error) result 10 9 11 10 val resolve_module_reference : 12 11 Env.t ->
+41 -51
src/xref2/tools.ml
··· 214 214 type resolve_module_result = 215 215 ( Cpath.Resolved.module_ * Component.Module.t Component.Delayed.t, 216 216 simple_module_lookup_error ) 217 - Result.result 217 + result 218 218 219 219 type resolve_module_type_result = 220 220 ( Cpath.Resolved.module_type * Component.ModuleType.t, 221 221 simple_module_type_lookup_error ) 222 - Result.result 222 + result 223 223 224 224 type resolve_type_result = 225 - ( Cpath.Resolved.type_ * Find.careful_type, 226 - simple_type_lookup_error ) 227 - Result.result 225 + (Cpath.Resolved.type_ * Find.careful_type, simple_type_lookup_error) result 228 226 229 227 type resolve_value_result = 230 - (Cpath.Resolved.value * Find.value, simple_value_lookup_error) Result.result 228 + (Cpath.Resolved.value * Find.value, simple_value_lookup_error) result 231 229 232 230 type resolve_class_type_result = 233 231 ( Cpath.Resolved.class_type * Find.careful_class, 234 232 simple_type_lookup_error ) 235 - Result.result 233 + result 236 234 237 235 type ('a, 'b, 'c) sig_map = { type_ : 'a; module_ : 'b; module_type : 'c } 238 236 ··· 285 283 type result = 286 284 ( Component.Module.t Component.Delayed.t, 287 285 simple_module_lookup_error ) 288 - Result.result 286 + Result.t 289 287 290 288 let equal = ( = ) 291 289 ··· 298 296 type result = 299 297 ( Component.Signature.t * Component.Substitution.t, 300 298 [ `Parent of parent_lookup_error ] ) 301 - Result.result 299 + Result.t 302 300 303 301 let equal = ( = ) 304 302 ··· 328 326 module ExpansionOfModuleMemo = MakeMemo (struct 329 327 type t = Cpath.Resolved.module_ 330 328 331 - type result = (expansion, expansion_of_module_error) Result.result 329 + type result = (expansion, expansion_of_module_error) Result.t 332 330 333 331 let equal = ( = ) 334 332 ··· 552 550 and lookup_module_gpath : 553 551 Env.t -> 554 552 Odoc_model.Paths.Path.Resolved.Module.t -> 555 - ( Component.Module.t Component.Delayed.t, 556 - simple_module_lookup_error ) 557 - Result.result = 553 + (Component.Module.t Component.Delayed.t, simple_module_lookup_error) result 554 + = 558 555 fun env path -> 559 556 match path with 560 557 | `Identifier i -> ··· 589 586 and lookup_module : 590 587 Env.t -> 591 588 Cpath.Resolved.module_ -> 592 - ( Component.Module.t Component.Delayed.t, 593 - simple_module_lookup_error ) 594 - Result.result = 589 + (Component.Module.t Component.Delayed.t, simple_module_lookup_error) result 590 + = 595 591 fun env' path' -> 596 592 let lookup env (path : ExpansionOfModuleMemo.M.key) = 597 593 match path with ··· 630 626 and lookup_module_type_gpath : 631 627 Env.t -> 632 628 Odoc_model.Paths.Path.Resolved.ModuleType.t -> 633 - (Component.ModuleType.t, simple_module_type_lookup_error) Result.result = 629 + (Component.ModuleType.t, simple_module_type_lookup_error) result = 634 630 fun env path -> 635 631 match path with 636 632 | `Identifier i -> ··· 655 651 and lookup_module_type : 656 652 Env.t -> 657 653 Cpath.Resolved.module_type -> 658 - (Component.ModuleType.t, simple_module_type_lookup_error) Result.result = 654 + (Component.ModuleType.t, simple_module_type_lookup_error) result = 659 655 fun env path -> 660 656 let lookup env = 661 657 match path with ··· 682 678 Cpath.Resolved.parent -> 683 679 ( Component.Signature.t * Component.Substitution.t, 684 680 [ `Parent of parent_lookup_error ] ) 685 - Result.result = 681 + result = 686 682 fun env' parent' -> 687 683 let lookup env parent = 688 684 match parent with ··· 714 710 Odoc_model.Paths.Path.Resolved.Module.t -> 715 711 ( Component.Signature.t * Component.Substitution.t, 716 712 [ `Parent of parent_lookup_error ] ) 717 - Result.result = 713 + result = 718 714 fun env parent -> 719 715 lookup_module_gpath env parent 720 716 |> map_error (fun e -> `Parent (`Parent_module e)) ··· 728 724 and lookup_type_gpath : 729 725 Env.t -> 730 726 Odoc_model.Paths.Path.Resolved.Type.t -> 731 - (Find.careful_type, simple_type_lookup_error) Result.result = 727 + (Find.careful_type, simple_type_lookup_error) result = 732 728 fun env p -> 733 729 let do_type p name = 734 730 lookup_parent_gpath env p ··· 774 770 and lookup_value_gpath : 775 771 Env.t -> 776 772 Odoc_model.Paths.Path.Resolved.Value.t -> 777 - (Find.value, simple_value_lookup_error) Result.result = 773 + (Find.value, simple_value_lookup_error) result = 778 774 fun env p -> 779 775 let do_value p name = 780 776 lookup_parent_gpath env p ··· 797 793 and lookup_class_type_gpath : 798 794 Env.t -> 799 795 Odoc_model.Paths.Path.Resolved.ClassType.t -> 800 - (Find.careful_class, simple_type_lookup_error) Result.result = 796 + (Find.careful_class, simple_type_lookup_error) result = 801 797 fun env p -> 802 798 let do_type p name = 803 799 lookup_parent_gpath env p ··· 831 827 and lookup_type : 832 828 Env.t -> 833 829 Cpath.Resolved.type_ -> 834 - (Find.careful_type, simple_type_lookup_error) Result.result = 830 + (Find.careful_type, simple_type_lookup_error) result = 835 831 fun env p -> 836 832 let do_type p name = 837 833 lookup_parent env p |> map_error (fun e -> (e :> simple_type_lookup_error)) ··· 862 858 res 863 859 864 860 and lookup_value : 865 - Env.t -> 866 - Cpath.Resolved.value -> 867 - (_, simple_value_lookup_error) Result.result = 861 + Env.t -> Cpath.Resolved.value -> (_, simple_value_lookup_error) result = 868 862 fun env p -> 869 863 match p with 870 864 | `Value (p, id) -> ··· 878 872 and lookup_class_type : 879 873 Env.t -> 880 874 Cpath.Resolved.class_type -> 881 - (Find.careful_class, simple_type_lookup_error) Result.result = 875 + (Find.careful_class, simple_type_lookup_error) result = 882 876 fun env p -> 883 877 let do_type p name = 884 878 lookup_parent env p |> map_error (fun e -> (e :> simple_type_lookup_error)) ··· 1522 1516 and module_type_expr_of_module_decl : 1523 1517 Env.t -> 1524 1518 Component.Module.decl -> 1525 - ( Component.ModuleType.expr, 1526 - simple_module_type_expr_of_module_error ) 1527 - Result.result = 1519 + (Component.ModuleType.expr, simple_module_type_expr_of_module_error) result 1520 + = 1528 1521 fun env decl -> 1529 1522 match decl with 1530 1523 | Component.Module.Alias (`Resolved r, _) -> ··· 1545 1538 and module_type_expr_of_module : 1546 1539 Env.t -> 1547 1540 Component.Module.t -> 1548 - ( Component.ModuleType.expr, 1549 - simple_module_type_expr_of_module_error ) 1550 - Result.result = 1541 + (Component.ModuleType.expr, simple_module_type_expr_of_module_error) result 1542 + = 1551 1543 fun env m -> module_type_expr_of_module_decl env m.type_ 1552 1544 1553 1545 and expansion_of_module_path : 1554 1546 Env.t -> 1555 1547 strengthen:bool -> 1556 1548 Cpath.module_ -> 1557 - (expansion, expansion_of_module_error) Result.result = 1549 + (expansion, expansion_of_module_error) result = 1558 1550 fun env ~strengthen path -> 1559 1551 match resolve_module env path with 1560 1552 | Ok (p', m) -> ( ··· 1578 1570 Env.t -> 1579 1571 Component.Signature.t -> 1580 1572 Component.ModuleType.substitution list -> 1581 - (Component.Signature.t, expansion_of_module_error) Result.result = 1573 + (Component.Signature.t, expansion_of_module_error) result = 1582 1574 fun env sg subs -> 1583 1575 let open Odoc_utils.ResultMonad in 1584 1576 List.fold_left ··· 1586 1578 (Ok sg) subs 1587 1579 1588 1580 and assert_not_functor : type err. 1589 - expansion -> (Component.Signature.t, err) Result.result = function 1581 + expansion -> (Component.Signature.t, err) result = function 1590 1582 | Signature sg -> Ok sg 1591 1583 | _ -> assert false 1592 1584 ··· 1605 1597 Env.t -> 1606 1598 Component.ModuleType.type_of_desc -> 1607 1599 original_path:Cpath.module_ -> 1608 - (expansion, expansion_of_module_error) Result.result = 1600 + (expansion, expansion_of_module_error) result = 1609 1601 fun env desc ~original_path:_ -> 1610 1602 let p, strengthen = 1611 1603 match desc with ModPath p -> (p, false) | StructInclude p -> (p, true) ··· 1625 1617 and signature_of_u_module_type_expr : 1626 1618 Env.t -> 1627 1619 Component.ModuleType.U.expr -> 1628 - (Component.Signature.t, expansion_of_module_error) Result.result = 1620 + (Component.Signature.t, expansion_of_module_error) result = 1629 1621 fun env m -> 1630 1622 match m with 1631 1623 | Component.ModuleType.U.Path p -> ( ··· 1655 1647 and expansion_of_module_type_expr : 1656 1648 Env.t -> 1657 1649 Component.ModuleType.expr -> 1658 - (expansion, expansion_of_module_error) Result.result = 1650 + (expansion, expansion_of_module_error) result = 1659 1651 fun env m -> 1660 1652 match m with 1661 1653 | Component.ModuleType.Path { p_expansion = Some e; _ } -> ··· 1685 1677 and expansion_of_module_type : 1686 1678 Env.t -> 1687 1679 Component.ModuleType.t -> 1688 - (expansion, expansion_of_module_error) Result.result = 1680 + (expansion, expansion_of_module_error) result = 1689 1681 fun env m -> 1690 1682 match m.expr with 1691 1683 | None -> Error `OpaqueModule ··· 1694 1686 and expansion_of_module_decl : 1695 1687 Env.t -> 1696 1688 Component.Module.decl -> 1697 - (expansion, expansion_of_module_error) Result.result = 1689 + (expansion, expansion_of_module_error) result = 1698 1690 fun env decl -> 1699 1691 match decl with 1700 1692 (* | Component.Module.Alias (_, Some e) -> Ok (expansion_of_simple_expansion e) *) ··· 1703 1695 | Component.Module.ModuleType expr -> expansion_of_module_type_expr env expr 1704 1696 1705 1697 and expansion_of_module : 1706 - Env.t -> 1707 - Component.Module.t -> 1708 - (expansion, expansion_of_module_error) Result.result = 1698 + Env.t -> Component.Module.t -> (expansion, expansion_of_module_error) result 1699 + = 1709 1700 fun env m -> 1710 1701 expansion_of_module_decl env m.type_ >>= function 1711 1702 | Signature sg -> ··· 1723 1714 Env.t -> 1724 1715 Cpath.Resolved.module_ -> 1725 1716 Component.Module.t -> 1726 - (expansion, expansion_of_module_error) Result.result = 1717 + (expansion, expansion_of_module_error) result = 1727 1718 fun env' path m -> 1728 1719 let id = path in 1729 1720 let run env _id = expansion_of_module env m in ··· 1773 1764 Env.t -> 1774 1765 Component.ModuleType.substitution -> 1775 1766 Component.Signature.t -> 1776 - (Component.Signature.t, expansion_of_module_error) Result.result = 1767 + (Component.Signature.t, expansion_of_module_error) result = 1777 1768 fun env sub sg -> 1778 1769 (* Used when we haven't finished the substitution. For example, if the 1779 1770 substitution is `M.t = u`, this function is used to map the declaration ··· 2117 2108 Env.t -> 2118 2109 Component.Signature.t -> 2119 2110 ModuleName.t -> 2120 - ( Component.Module.t Component.Delayed.t, 2121 - simple_module_lookup_error ) 2122 - Result.result = 2111 + (Component.Module.t Component.Delayed.t, simple_module_lookup_error) result 2112 + = 2123 2113 fun env sg name -> 2124 2114 match Find.careful_module_in_sig sg name with 2125 2115 | Some (`FModule (_, m)) -> Ok (Component.Delayed.put_val m) ··· 2133 2123 ModuleTypeName.t -> 2134 2124 ( Component.ModuleType.t Component.Delayed.t, 2135 2125 simple_module_type_lookup_error ) 2136 - Result.result = 2126 + result = 2137 2127 fun _env sg name -> 2138 2128 match Find.careful_module_type_in_sig sg name with 2139 2129 | Some (`FModuleType (_, m)) -> Ok (Component.Delayed.put_val m)
+21 -28
src/xref2/tools.mli
··· 46 46 val lookup_module : 47 47 Env.t -> 48 48 Cpath.Resolved.module_ -> 49 - ( Component.Module.t Component.Delayed.t, 50 - simple_module_lookup_error ) 51 - Result.result 49 + (Component.Module.t Component.Delayed.t, simple_module_lookup_error) result 52 50 (** [lookup_module ~mark_substituted env p] takes a resolved module cpath [p] 53 51 and an environment and returns a representation of the module. *) 54 52 55 53 val lookup_module_type : 56 54 Env.t -> 57 55 Cpath.Resolved.module_type -> 58 - (Component.ModuleType.t, simple_module_type_lookup_error) Result.result 56 + (Component.ModuleType.t, simple_module_type_lookup_error) result 59 57 (** [lookup_module_type ~mark_substituted env p] takes a resolved module type 60 58 cpath and an environment and returns a representation of the module type. *) 61 59 62 60 val lookup_type : 63 61 Env.t -> 64 62 Cpath.Resolved.type_ -> 65 - (Find.careful_type, simple_type_lookup_error) Result.result 63 + (Find.careful_type, simple_type_lookup_error) result 66 64 (** [lookup_type env p] takes a resolved type path and an environment and 67 65 returns a representation of the type. The type can be an ordinary type, a 68 66 class type or a class. If the type has been destructively substituted, the ··· 71 69 val lookup_class_type : 72 70 Env.t -> 73 71 Cpath.Resolved.class_type -> 74 - (Find.careful_class, simple_type_lookup_error) Result.result 72 + (Find.careful_class, simple_type_lookup_error) result 75 73 (** [lookup_class_type env p] takes a resolved class type path and an 76 74 environment and returns a representation of the class type. The type can be 77 75 a class type or a class. *) ··· 81 79 Cpath.module_ -> 82 80 ( Cpath.Resolved.module_ * Component.Module.t Component.Delayed.t, 83 81 simple_module_lookup_error ) 84 - Result.result 82 + result 85 83 (** [resolve_module ~mark_substituted ~add_canonical env p] takes an unresolved 86 84 module path and an environment and returns a tuple of the resolved module 87 85 path alongside a representation of the module itself. *) ··· 91 89 Cpath.module_type -> 92 90 ( Cpath.Resolved.module_type * Component.ModuleType.t, 93 91 simple_module_type_lookup_error ) 94 - Result.result 92 + result 95 93 (** [resolve_module_type ~mark_substituted ~add_canonical env p] takes an 96 94 unresolved module type path and an environment and returns a tuple of the 97 95 resolved module type path alongside a representation of the module type ··· 100 98 val resolve_type : 101 99 Env.t -> 102 100 Cpath.type_ -> 103 - ( Cpath.Resolved.type_ * Find.careful_type, 104 - simple_type_lookup_error ) 105 - Result.result 101 + (Cpath.Resolved.type_ * Find.careful_type, simple_type_lookup_error) result 106 102 (** [resolve_type env p] takes an unresolved type path and an environment and 107 103 returns a tuple of the resolved type path alongside a representation of the 108 104 type itself. As with {!val:lookup_type} the returned type is either the ··· 114 110 Cpath.class_type -> 115 111 ( Cpath.Resolved.class_type * Find.careful_class, 116 112 simple_type_lookup_error ) 117 - Result.result 113 + result 118 114 (** [resolve_class_type env p] takes an unresolved class type path and an 119 115 environment and returns a tuple of the resolved class type path alongside a 120 116 representation of the class type itself. As with {!val:lookup_type} the ··· 132 128 val resolve_module_path : 133 129 Env.t -> 134 130 Cpath.module_ -> 135 - (Cpath.Resolved.module_, simple_module_lookup_error) Result.result 131 + (Cpath.Resolved.module_, simple_module_lookup_error) result 136 132 137 133 val resolve_module_type_path : 138 134 Env.t -> 139 135 Cpath.module_type -> 140 - (Cpath.Resolved.module_type, simple_module_type_lookup_error) Result.result 136 + (Cpath.Resolved.module_type, simple_module_type_lookup_error) result 141 137 142 138 val resolve_type_path : 143 139 Env.t -> 144 140 Cpath.type_ -> 145 - (Cpath.Resolved.type_, simple_type_lookup_error) Result.result 141 + (Cpath.Resolved.type_, simple_type_lookup_error) result 146 142 147 143 val resolve_value_path : 148 144 Env.t -> 149 145 Cpath.value -> 150 - (Cpath.Resolved.value, simple_value_lookup_error) Result.result 146 + (Cpath.Resolved.value, simple_value_lookup_error) result 151 147 152 148 val resolve_class_type_path : 153 149 Env.t -> 154 150 Cpath.class_type -> 155 - (Cpath.Resolved.class_type, simple_type_lookup_error) Result.result 151 + (Cpath.Resolved.class_type, simple_type_lookup_error) result 156 152 157 153 (** {2 Re-resolve functions} *) 158 154 ··· 203 199 val prefix_signature : 204 200 Cpath.Resolved.parent * Component.Signature.t -> Component.Signature.t 205 201 206 - val assert_not_functor : 207 - expansion -> (Component.Signature.t, 'err) Result.result 202 + val assert_not_functor : expansion -> (Component.Signature.t, 'err) result 208 203 209 204 val expansion_of_module_path : 210 205 Env.t -> 211 206 strengthen:bool -> 212 207 Cpath.module_ -> 213 - (expansion, expansion_of_module_error) Result.result 208 + (expansion, expansion_of_module_error) result 214 209 215 210 val expansion_of_module : 216 - Env.t -> 217 - Component.Module.t -> 218 - (expansion, expansion_of_module_error) Result.result 211 + Env.t -> Component.Module.t -> (expansion, expansion_of_module_error) result 219 212 220 213 val expansion_of_module_type : 221 214 Env.t -> 222 215 Component.ModuleType.t -> 223 - (expansion, expansion_of_module_error) Result.result 216 + (expansion, expansion_of_module_error) result 224 217 225 218 val class_signature_of_class_type : 226 219 Env.t -> Component.ClassType.t -> Component.ClassSignature.t option ··· 233 226 val expansion_of_module_type_expr : 234 227 Env.t -> 235 228 Component.ModuleType.expr -> 236 - (expansion, expansion_of_module_error) Result.result 229 + (expansion, expansion_of_module_error) result 237 230 (** The following functions are use for the resolution of 238 231 {{!type:Odoc_model.Paths.Fragment.t}Fragments} Whilst resolving fragments it 239 232 is necessary to process them in order, applying the 'with' expression of ··· 247 240 val signature_of_u_module_type_expr : 248 241 Env.t -> 249 242 Component.ModuleType.U.expr -> 250 - (Component.Signature.t, expansion_of_module_error) Result.result 243 + (Component.Signature.t, expansion_of_module_error) result 251 244 (** The following functions are use for the resolution of 252 245 {{!type:Odoc_model.Paths.Fragment.t}Fragments} Whilst resolving fragments it 253 246 is necessary to process them in order, applying the 'with' expression of ··· 320 313 Env.t -> 321 314 Component.ModuleType.substitution -> 322 315 Component.Signature.t -> 323 - (Component.Signature.t, expansion_of_module_error) Result.result 316 + (Component.Signature.t, expansion_of_module_error) result 324 317 (** [fragmap ~mark_substituted env sub sg] takes an environment [env] and 325 318 signature [sg], and a fragment substitution (e.g. [ModuleSubst] to 326 319 destructively substitute a module), and returns the substituted signature. ··· 330 323 Env.t -> 331 324 Component.Signature.t -> 332 325 Component.ModuleType.substitution list -> 333 - (Component.Signature.t, expansion_of_module_error) Result.result 326 + (Component.Signature.t, expansion_of_module_error) result 334 327 (** [handle_signature_with_subs ~mark_substituted env sg subs] applies the 335 328 fragment modifiers [subs], in order, to the supplied signature [sg]. *) 336 329
+1 -1
test/odoc_print/print_index.ml
··· 4 4 let inp = Fpath.v inp in 5 5 let index = 6 6 Odoc_odoc.Odoc_file.load_index inp |> function 7 - | Result.Ok x -> x 7 + | Ok x -> x 8 8 | _ -> failwith "failed to load index" 9 9 in 10 10 let rec tree_to_yojson
+1 -1
test/xref2/resolve/test.md
··· 62 62 over the tree. For this example the interesting point comes when we get to 63 63 looking at the manifest for type `u`. We see that we have a `Constr` that has a 64 64 path in it, so we look up the component from the path via the function 65 - `Tools.lookup_type_from_model_path`. This returns us a `Result.result` 65 + `Tools.lookup_type_from_model_path`. This returns us a `result` 66 66 containing the resolved path and the `Component.Type.t` that represents the 67 67 type `t`. We don't particularly care about this, but the returned path we use 68 68 in place of the path we had before.