Skip to content

Commit ea255bf

Browse files
authored
refactor(stdune): hide [File_kind.Option] (ocaml#12126)
Signed-off-by: Rudi Grinberg <[email protected]>
1 parent 57f415a commit ea255bf

3 files changed

Lines changed: 32 additions & 45 deletions

File tree

otherlibs/stdune/src/dune_filesystem_stubs.ml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
module File_kind = struct
2+
include File_kind
3+
4+
module Option = struct
5+
[@@@warning "-37"]
6+
7+
(* The values are constructed on the C-side *)
8+
type t =
9+
| S_REG
10+
| S_DIR
11+
| S_CHR
12+
| S_BLK
13+
| S_LNK
14+
| S_FIFO
15+
| S_SOCK
16+
| UNKNOWN
17+
18+
let elim ~none ~some t =
19+
match t with
20+
| S_REG -> some (S_REG : Unix.file_kind)
21+
| S_DIR -> some S_DIR
22+
| S_CHR -> some S_CHR
23+
| S_BLK -> some S_BLK
24+
| S_LNK -> some S_LNK
25+
| S_FIFO -> some S_FIFO
26+
| S_SOCK -> some S_SOCK
27+
| UNKNOWN -> none ()
28+
;;
29+
end
30+
end
31+
132
module Readdir_result = struct
233
[@@@warning "-37"]
334

@@ -19,7 +50,7 @@ let readdir_with_kind_if_available_win32 : Unix.dir_handle -> Readdir_result.t =
1950
complicated. (there's an additional OCaml abstraction layer) *)
2051
match Unix.readdir dir with
2152
| exception End_of_file -> Readdir_result.End_of_directory
22-
| entry -> Entry (entry, UNKNOWN)
53+
| entry -> Entry (entry, File_kind.Option.UNKNOWN)
2354
;;
2455

2556
let readdir_with_kind_if_available : Unix.dir_handle -> Readdir_result.t =

otherlibs/stdune/src/file_kind.ml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,4 @@ let equal x y =
4444
| S_SOCK, S_SOCK -> true
4545
;;
4646

47-
module Option = struct
48-
[@@@warning "-37"]
49-
50-
(* The values are constructed on the C-side *)
51-
type t =
52-
| S_REG
53-
| S_DIR
54-
| S_CHR
55-
| S_BLK
56-
| S_LNK
57-
| S_FIFO
58-
| S_SOCK
59-
| UNKNOWN
60-
61-
let elim ~none ~some t =
62-
match t with
63-
| S_REG -> some (S_REG : Unix.file_kind)
64-
| S_DIR -> some S_DIR
65-
| S_CHR -> some S_CHR
66-
| S_BLK -> some S_BLK
67-
| S_LNK -> some S_LNK
68-
| S_FIFO -> some S_FIFO
69-
| S_SOCK -> some S_SOCK
70-
| UNKNOWN -> none ()
71-
;;
72-
end
73-
7447
let to_dyn t = Dyn.String (to_string t)

otherlibs/stdune/src/file_kind.mli

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,3 @@ val to_string : t -> string
1111
val to_string_hum : t -> string
1212
val equal : t -> t -> bool
1313
val to_dyn : t -> Dyn.t
14-
15-
module Option : sig
16-
type file_kind := t
17-
18-
(* The values are constructed on the C-side *)
19-
type t =
20-
| S_REG
21-
| S_DIR
22-
| S_CHR
23-
| S_BLK
24-
| S_LNK
25-
| S_FIFO
26-
| S_SOCK
27-
| UNKNOWN
28-
29-
val elim : none:(unit -> 'a) -> some:(file_kind -> 'a) -> t -> 'a
30-
end

0 commit comments

Comments
 (0)