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
type t =
| LibFile of string
| SourceFile of string
| JsonFile of string
| ResourceFile of string [@@deriving (show, eq)]
include
struct
let _ = fun (_ : t) -> ()
let rec pp :
Format.formatter -> t -> unit
=
(( fun fmt ->
function
| LibFile a0 ->
(Format.fprintf fmt
"(@[<2>File_key.LibFile@ ";
(Format.fprintf fmt "%S") a0;
Format.fprintf fmt "@])")
| SourceFile a0 ->
(Format.fprintf fmt
"(@[<2>File_key.SourceFile@ ";
(Format.fprintf fmt "%S") a0;
Format.fprintf fmt "@])")
| JsonFile a0 ->
(Format.fprintf fmt
"(@[<2>File_key.JsonFile@ ";
(Format.fprintf fmt "%S") a0;
Format.fprintf fmt "@])")
| ResourceFile a0 ->
(Format.fprintf fmt
"(@[<2>File_key.ResourceFile@ ";
(Format.fprintf fmt "%S") a0;
Format.fprintf fmt "@])"))
[@ocaml.warning "-39"][@ocaml.warning "-A"])
and show : t -> string =
fun x -> Format.asprintf "%a" pp x[@@ocaml.warning
"-32"]
let _ = pp
and _ = show
let rec equal : t -> t -> bool =
(( fun lhs rhs ->
match (lhs, rhs) with
| (LibFile lhs0, LibFile rhs0) ->
((fun (a : string) b -> a = b)) lhs0 rhs0
| (SourceFile lhs0, SourceFile rhs0) ->
((fun (a : string) b -> a = b)) lhs0 rhs0
| (JsonFile lhs0, JsonFile rhs0) ->
((fun (a : string) b -> a = b)) lhs0 rhs0
| (ResourceFile lhs0, ResourceFile rhs0) ->
((fun (a : string) b -> a = b)) lhs0 rhs0
| _ -> false)
[@ocaml.warning "-39"][@ocaml.warning "-A"])[@@ocaml.warning "-39"]
let _ = equal
end[@@ocaml.doc "@inline"][@@merlin.hide ]
let to_string =
function | LibFile x | SourceFile x | JsonFile x | ResourceFile x -> x
let to_path =
function | LibFile x | SourceFile x | JsonFile x | ResourceFile x -> Ok x
let compare =
let order_of_filename =
function
| LibFile _ -> 1
| SourceFile _ -> 2
| JsonFile _ -> 2
| ResourceFile _ -> 3 in
fun a b ->
let k = (order_of_filename a) - (order_of_filename b) in
if k <> 0 then k else String.compare (to_string a) (to_string b)
let compare_opt a b =
match (a, b) with
| (Some _, None) -> (-1)
| (None, Some _) -> 1
| (None, None) -> 0
| (Some a, Some b) -> compare a b
let is_lib_file =
function
| LibFile _ -> true
| SourceFile _ -> false
| JsonFile _ -> false
| ResourceFile _ -> false
let map f =
function
| LibFile filename -> LibFile (f filename)
| SourceFile filename -> SourceFile (f filename)
| JsonFile filename -> JsonFile (f filename)
| ResourceFile filename -> ResourceFile (f filename)
let exists f =
function
| LibFile filename | SourceFile filename | JsonFile filename | ResourceFile
filename -> f filename
let check_suffix filename suffix =
exists (fun fn -> Filename.check_suffix fn suffix) filename
let chop_suffix filename suffix =
map (fun fn -> Filename.chop_suffix fn suffix) filename
let with_suffix filename suffix = map (fun fn -> fn ^ suffix) filename