Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 7c93e74

Browse files
committed
Remove RResult
1 parent 46395d0 commit 7c93e74

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

src/RResult.ml

-6
This file was deleted.

src/References.ml

+37-27
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,33 @@ let definedForLoc ~file ~getModule locKind =
6464
| NotFound -> None
6565
| LocalReference (stamp, tip) | Definition (stamp, tip) ->
6666
inner ~file stamp tip
67-
| GlobalReference (moduleName, path, tip) ->
68-
(maybeLog ("Getting global " ^ moduleName);
69-
match getModule moduleName with
70-
| None -> Error ("Cannot get module " ^ moduleName)
71-
| Some file -> (
72-
let env = Query.fileEnv file in
73-
match Query.resolvePath ~env ~path ~getModule with
74-
| None -> Error ("Cannot resolve path " ^ pathToString path)
75-
| Some (env, name) -> (
76-
match Query.exportedForTip ~env name tip with
77-
| None ->
78-
Error ("Exported not found for tip " ^ name ^ " > " ^ tipToString tip)
79-
| Some stamp -> (
80-
maybeLog ("Getting for " ^ string_of_int stamp ^ " in " ^ name);
81-
82-
match inner ~file:env.file stamp tip with
83-
| None -> Error "could not get defined"
84-
| Some res ->
85-
maybeLog "Yes!! got it";
86-
Ok res))))
87-
|> RResult.toOptionAndLog
67+
| GlobalReference (moduleName, path, tip) -> (
68+
maybeLog ("Getting global " ^ moduleName);
69+
match getModule moduleName with
70+
| None ->
71+
Log.log ("Cannot get module " ^ moduleName);
72+
None
73+
| Some file -> (
74+
let env = Query.fileEnv file in
75+
match Query.resolvePath ~env ~path ~getModule with
76+
| None ->
77+
Log.log ("Cannot resolve path " ^ pathToString path);
78+
None
79+
| Some (env, name) -> (
80+
match Query.exportedForTip ~env name tip with
81+
| None ->
82+
Log.log
83+
("Exported not found for tip " ^ name ^ " > " ^ tipToString tip);
84+
None
85+
| Some stamp -> (
86+
maybeLog ("Getting for " ^ string_of_int stamp ^ " in " ^ name);
87+
match inner ~file:env.file stamp tip with
88+
| None ->
89+
Log.log "could not get defined";
90+
None
91+
| Some res ->
92+
maybeLog "Yes!! got it";
93+
Some res))))
8894

8995
let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
9096
match Hashtbl.find_opt pathsForModule file.moduleName with
@@ -97,19 +103,23 @@ let alternateDeclared ~file ~pathsForModule ~getUri declared tip =
97103
let intfUri = Uri2.fromPath intf in
98104
let implUri = Uri2.fromPath impl in
99105
if intfUri = file.uri then
100-
match getUri implUri |> RResult.toOptionAndLog with
101-
| None -> None
102-
| Some (file, extra) -> (
106+
match getUri implUri with
107+
| Error e ->
108+
Log.log e;
109+
None
110+
| Ok (file, extra) -> (
103111
match
104112
Query.declaredForExportedTip ~stamps:file.stamps
105113
~exported:file.contents.exported declared.name.txt tip
106114
with
107115
| None -> None
108116
| Some declared -> Some (file, extra, declared))
109117
else
110-
match getUri intfUri |> RResult.toOptionAndLog with
111-
| None -> None
112-
| Some (file, extra) -> (
118+
match getUri intfUri with
119+
| Error e ->
120+
Log.log e;
121+
None
122+
| Ok (file, extra) -> (
113123
match
114124
Query.declaredForExportedTip ~stamps:file.stamps
115125
~exported:file.contents.exported declared.name.txt tip

src/State.ml

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ let converter src =
1515

1616
let newDocsForCmt ~moduleName cmtCache changed cmt src =
1717
let uri = Uri2.fromPath (src |? cmt) in
18-
match
19-
Process_406.fileForCmt ~moduleName ~uri cmt (converter src)
20-
|> RResult.toOptionAndLog
21-
with
22-
| None -> None
23-
| Some file ->
18+
match Process_406.fileForCmt ~moduleName ~uri cmt (converter src) with
19+
| Error e ->
20+
Log.log e;
21+
None
22+
| Ok file ->
2423
Hashtbl.replace cmtCache cmt (changed, file);
2524
Some file
2625

0 commit comments

Comments
 (0)