Skip to content

Commit

Permalink
fix: rewrite the core
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Sep 17, 2022
1 parent d05c342 commit 8bb08a7
Show file tree
Hide file tree
Showing 34 changed files with 502 additions and 910 deletions.
8 changes: 7 additions & 1 deletion bantorra.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ dev-repo: "git+https://github.com/RedPRL/bantorra.git"
depends: [
"dune" {>= "2.0"}
"ocaml" {>= "5.0"}
"asai"
"algaeff" {>= "0.2"}
"bos" {>= "0.2"}
"bwd" {>= "2.1"}
"conf-git" {post}
"ezjsonm" {>= "1.2"}
"json-data-encoding" {>= "0.9"}
"ocamlfind" {>= "1.8"}
"odoc" {with-doc}
]
pin-depends: [
[ "asai.0.1.0~dev" "git+https://github.com/RedPRL/asai" ]
]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "build" "-p" name "-j" jobs "@runtest"] {with-test}
["dune" "build" "-p" name "-j" jobs "@doc"] {with-doc}
Expand Down
24 changes: 11 additions & 13 deletions src/basis/BantorraBasis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@

(** {1 Main Modules} *)

module UnitPath = UnitPath
(** Unit paths. *)

module FilePath = FilePath
(** Basic path manipulation. *)

module File = File
(** Basic I/O and path manipulation. *)
(** Basic I/O. *)

module Marshal = Marshal
(** Serialization. *)

(**/**)
(** {1 Error Handling} *)

(** {1 Helper Modules} *)
module ErrorCode = ErrorCode
(** Error codes. *)

module Error = Error
(** Generic error reporting functions. *)

module Errors = Errors
(** Specialized error reporting functions. *)

module Util = Util
(** Utility functions. *)

module ResultMonad = ResultMonad
(** The {!type:result} monad. *)
(** Error reporting. *)
21 changes: 1 addition & 20 deletions src/basis/Error.ml
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
let[@inline] error_msg ~tag ~src msg =
Format.kasprintf tag "Reported from %s:\n %s" src msg

let error_msgf ~tag ~src =
Format.kasprintf (error_msg ~tag ~src)

let append_tag ~tag ~earlier =
Format.kasprintf tag "%s\n%s" earlier

let append_error_msg ~tag ~earlier =
error_msg ~tag:(append_tag ~tag ~earlier)

let append_error_msgf ~tag ~earlier =
error_msgf ~tag:(append_tag ~tag ~earlier)

let pp_lines fmt msg =
Format.fprintf fmt "@[<v>";
Format.(pp_print_list ~pp_sep:pp_print_cut pp_print_string) fmt @@
String.split_on_char '\n' msg;
Format.fprintf fmt "@]"
include Asai.Logger.Make(ErrorCode)
15 changes: 1 addition & 14 deletions src/basis/Error.mli
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
val error_msg : tag:(string -> ('a, 'b) result) -> src:string -> string -> ('a, 'b) result
(** Turn an error message into an error. *)

val error_msgf : tag:(string -> ('a, 'b) result) -> src:string -> ('c, Format.formatter, unit, ('a, 'b) result) format4 -> 'c
(** Format an error message. *)

val append_error_msg : tag:(string -> ('a, 'b) result) -> earlier:string -> src:string -> string -> ('a, 'b) result
(** Append an error message to an earlier error. *)

val append_error_msgf : tag:(string -> ('a, 'b) result) -> earlier:string -> src:string -> ('c, Format.formatter, unit, ('a, 'b) result) format4 -> 'c
(** Format and append an error message to an earlier error. *)

val pp_lines : Format.formatter -> string -> unit
(** Pretty printer that hints newlines for ['\n']. *)
include Asai.Logger.S with module Code := ErrorCode
19 changes: 19 additions & 0 deletions src/basis/ErrorCode.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type t =
[ `System
| `AnchorNotFound
| `JSONFormat
| `UnitNotFound
| `InvalidLibrary
| `InvalidRouter
]

let default_severity _ = Asai.Severity.Error

let to_string : t -> string =
function
| `System -> "sys"
| `AnchorNotFound -> "anchor"
| `JSONFormat -> "json"
| `UnitNotFound -> "unit"
| `InvalidLibrary -> "lib"
| `InvalidRouter -> "router"
20 changes: 0 additions & 20 deletions src/basis/Errors.ml

This file was deleted.

22 changes: 0 additions & 22 deletions src/basis/Errors.mli

This file was deleted.

Loading

0 comments on commit 8bb08a7

Please sign in to comment.