Debian Codegraph @

src/Util/ErrorT/Show.v

raw
1 From Coq Require Import List.
2 From Coq Require Import String.
3 Require Import Crypto.Util.Strings.Show.
4 Require Import Crypto.Util.ErrorT.
5 Import ListNotations.
6 Local Open Scope list_scope.
7 Local Open Scope string_scope.
8
9 Global Instance show_lvl_ErrorT {ErrT T} {show_ErrT : ShowLevel ErrT} {show_T : ShowLevel T}
10 : ShowLevel (@ErrorT ErrT T)
11 := fun v
12 => match v with
13 | Success v => show_lvl_app (fun 'tt => "Success") v
14 | Error msg => show_lvl_app (fun 'tt => "Error") msg
15 end.
16 Global Instance show_ErrorT {ErrT T} {show_ErrT : Show ErrT} {show_T : Show T} : Show (@ErrorT ErrT T)
17 := let _ := @ShowLevel_of_Show ErrT in
18 let _ := @ShowLevel_of_Show T in
19 _.
20
21 Global Instance show_lines_ErrorT {ErrT T} {show_lines_ErrT : ShowLines ErrT} {show_lines_T : ShowLines T}
22 : ShowLines (@ErrorT ErrT T)
23 := fun v
24 => let '(prefix, lines)
25 := match v with
26 | Success v => ("Success", show_lines v)
27 | Error msg => ("Error", show_lines msg)
28 end in
29 match lines with
30 | [] => [prefix ++ " ()"]
31 | [line] => [prefix ++ " " ++ line]
32 | lines => (([prefix ++ " ("]%string)
33 ++ (List.map (fun s => " " ++ s)%string lines)
34 ++ [")"])%list
35 end.