package grace
A fancy diagnostics library that allows your compilers to exit with grace
Install
Dune Dependency
Authors
Maintainers
Sources
grace-0.2.0.tbz
sha256=821df54882c9253eac69f47bcf3a71ffdc61c77fdae42587c32aada5b56cfeae
sha512=007afa83251da3ddecd874e120ea89dce0253c387a64a5fece69069d3486ec5eb6c82d6bf0febaf23dd322bd9eaadc2f7882e33f05a2e1fa18a41294e7dc3ba1
doc/src/grace/diagnostic.ml.html
Source file diagnostic.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
open! Import type ('a, 'b) format = ('a, Format.formatter, unit, 'b) format4 module Severity = struct module T = struct type t = | Help | Note | Warning | Error | Bug [@@deriving equal, compare, hash, sexp] end include T include Comparable.Make (T) let to_string = function | Help -> "help" | Error -> "error" | Warning -> "warning" | Note -> "note" | Bug -> "bug" ;; let pp = Format.pp_of_to_string to_string end module Priority = struct module T = struct type t = | Secondary | Primary [@@deriving equal, compare, hash, sexp] end include T include Comparable.Make (T) let is_primary = function | Primary -> true | Secondary -> false ;; let is_secondary = function | Primary -> false | Secondary -> true ;; let to_string = function | Primary -> "primary" | Secondary -> "secondary" ;; let pp = Format.pp_of_to_string to_string end module Message = struct module T = struct type t = Formatter.t -> unit let of_string str ppf = Format.(pp_print_list ~pp_sep:pp_force_newline pp_print_string) ppf @@ String.split_lines str ;; let to_string t = let buf = Buffer.create 512 in let ppf = Format.formatter_of_buffer buf in Format.pp_set_geometry ppf ~max_indent:2 ~margin:Int.max_value; t ppf; Format.pp_print_flush ppf (); Buffer.contents buf ;; let sexp_of_t = sexp_of_t_of_to_string to_string let t_of_sexp = t_of_sexp_of_of_string of_string let hash_fold_t state t = Hash.fold_string state (to_string t) let hash = Hash.of_fold hash_fold_t let compare = Comparable.lift Int.compare ~f:hash end include T include Comparable.Make (T) let create = of_string let createf = Format.dprintf let kcreatef = Format.kdprintf let pp ppf t = t ppf end module Label = struct type t = { range : Range.t ; priority : Priority.t ; message : Message.t } [@@deriving equal, compare, hash, sexp] let create ~range ~priority message = { range; priority; message } let createf ~range ~priority fmt = fmt |> Message.kcreatef @@ create ~range ~priority let kcreatef ~range ~priority kont fmt = fmt |> Message.kcreatef @@ fun msg -> kont (create ~range ~priority msg) ;; let primary = create ~priority:Primary let primaryf = createf ~priority:Primary let kprimaryf = kcreatef ~priority:Primary let secondary = create ~priority:Secondary let secondaryf = createf ~priority:Secondary let ksecondaryf = kcreatef ~priority:Secondary end type 'code t = { severity : Severity.t ; message : Message.t ; code : 'code option ; labels : Label.t list ; notes : Message.t list } [@@deriving sexp] let create ?(notes = []) ?(labels = []) ?code severity message = { notes; labels; severity; message; code } ;; let createf ?notes ?labels ?code severity fmt = fmt |> Message.kcreatef @@ create ?notes ?labels ?code severity ;; let kcreatef ?notes ?labels ?code kont severity fmt = fmt |> Message.kcreatef @@ fun msg -> kont (create ?notes ?labels ?code severity msg) ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>