-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename [Result] => [Rresult] and add another [Result] (refactor)
- Loading branch information
Showing
21 changed files
with
130 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,10 @@ | |
"opam", | ||
"pathspec", | ||
"rmtree", | ||
"rresult", | ||
"Stdenv", | ||
"subdir", | ||
"worktree", | ||
"worktrees" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(*******************************************************************************) | ||
(* Vcs - a Versatile OCaml Library for Git Operations *) | ||
(* Copyright (C) 2024 Mathieu Barbin <[email protected]> *) | ||
(* *) | ||
(* This file is part of Vcs. *) | ||
(* *) | ||
(* Vcs is free software; you can redistribute it and/or modify it under *) | ||
(* the terms of the GNU Lesser General Public License as published by the *) | ||
(* Free Software Foundation either version 3 of the License, or any later *) | ||
(* version, with the LGPL-3.0 Linking Exception. *) | ||
(* *) | ||
(* Vcs is distributed in the hope that it will be useful, but WITHOUT ANY *) | ||
(* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *) | ||
(* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and *) | ||
(* the file `NOTICE.md` at the root of this repository for more details. *) | ||
(* *) | ||
(* You should have received a copy of the GNU Lesser General Public License *) | ||
(* and the LGPL-3.0 Linking Exception along with this library. If not, see *) | ||
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *) | ||
(*******************************************************************************) | ||
|
||
open! Import | ||
|
||
type err = Vcs_rresult0.t [@@deriving sexp_of] | ||
type 'a t = ('a, err) Result.t [@@deriving sexp_of] | ||
type 'a result = 'a t | ||
|
||
include Non_raising.Make (Vcs_rresult0) | ||
|
||
let pp_error fmt (`Vcs err) = Stdlib.Format.pp_print_string fmt (Err.to_string_hum err) | ||
|
||
let open_error = function | ||
| Ok _ as r -> r | ||
| Error (`Vcs _) as r -> r | ||
;; | ||
|
||
let error_to_msg (r : 'a result) = | ||
Result.map_error r ~f:(fun (`Vcs err) -> `Msg (Err.to_string_hum err)) | ||
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(*_******************************************************************************) | ||
(*_ Vcs - a Versatile OCaml Library for Git Operations *) | ||
(*_ Copyright (C) 2024 Mathieu Barbin <[email protected]> *) | ||
(*_ *) | ||
(*_ This file is part of Vcs. *) | ||
(*_ *) | ||
(*_ Vcs is free software; you can redistribute it and/or modify it under *) | ||
(*_ the terms of the GNU Lesser General Public License as published by the *) | ||
(*_ Free Software Foundation either version 3 of the License, or any later *) | ||
(*_ version, with the LGPL-3.0 Linking Exception. *) | ||
(*_ *) | ||
(*_ Vcs is distributed in the hope that it will be useful, but WITHOUT ANY *) | ||
(*_ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *) | ||
(*_ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and *) | ||
(*_ the file `NOTICE.md` at the root of this repository for more details. *) | ||
(*_ *) | ||
(*_ You should have received a copy of the GNU Lesser General Public License *) | ||
(*_ and the LGPL-3.0 Linking Exception along with this library. If not, see *) | ||
(*_ <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *) | ||
(*_******************************************************************************) | ||
|
||
(** An [Vcs] API in the style of | ||
{{:https://erratique.ch/software/rresult/doc/Rresult/index.html#usage} Rresult}. *) | ||
|
||
type err = [ `Vcs of Err.t ] [@@deriving sexp_of] | ||
type 'a t = ('a, err) Result.t [@@deriving sexp_of] | ||
type 'a result = 'a t | ||
|
||
(** {1 Utils} | ||
This part exposes the functions prescribed by the | ||
{{:https://erratique.ch/software/rresult/doc/Rresult/index.html#usage} Rresult} | ||
usage design guidelines. *) | ||
|
||
val pp_error : Stdlib.Format.formatter -> [ `Vcs of Err.t ] -> unit | ||
val open_error : 'a result -> ('a, [> `Vcs of Err.t ]) Result.t | ||
val error_to_msg : 'a result -> ('a, [ `Msg of string ]) Result.t | ||
|
||
(** {1 Non raising API} | ||
The individual functions are documented the {!module:Vcs} module. *) | ||
|
||
include Non_raising.S with type 'a t := 'a Vcs0.t and type 'a result := 'a result |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.