Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: module kinds #6562

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/dune_rules/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,27 @@ module Kind = struct
| Wrapped_compat
| Root

let to_string = function
| Intf_only -> "intf_only"
| Virtual -> "virtual"
| Impl -> "impl"
| Alias -> "alias"
| Impl_vmodule -> "impl_vmodule"
| Wrapped_compat -> "wrapped_compat"
| Root -> "root"
let all =
[ (Intf_only, "intf_only")
; (Virtual, "virtual")
; (Impl, "impl")
; (Alias, "alias")
; (Impl_vmodule, "impl_vmodule")
; (Wrapped_compat, "wrapped_compat")
; (Root, "root")
]

let rev_all = List.rev_map ~f:(fun (x, y) -> (y, x)) all

let to_string s = Option.value_exn (List.assoc all s)

let to_dyn t = Dyn.string (to_string t)

let encode t = Dune_lang.Encoder.string (to_string t)

let decode =
let open Dune_lang.Decoder in
enum
[ ("intf_only", Intf_only)
; ("virtual", Virtual)
; ("impl", Impl)
; ("alias", Alias)
; ("impl_vmodule", Impl_vmodule)
; ("wrapped_compat", Wrapped_compat)
; ("root", Root)
]
enum rev_all

let has_impl = function
| Alias | Impl_vmodule | Wrapped_compat | Root | Impl -> true
Expand Down