summaryrefslogtreecommitdiff
path: root/lib/manifest.ml
diff options
context:
space:
mode:
authorยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2025-12-11 08:26:40 +0000
committerยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2025-12-11 08:26:40 +0000
commit5fc560944760ddcd38399a39f8ddd275cd4b7d2b (patch)
treec137781b573bed31492b679087db970b08d8c12d /lib/manifest.ml
parentb9d2d2eabedd6745eda4cb15270994e939d6b1b5 (diff)
downloadnixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar.gz
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar.bz2
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar.lz
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar.xz
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.tar.zst
nixtaml-5fc560944760ddcd38399a39f8ddd275cd4b7d2b.zip
move Kind module
Diffstat (limited to 'lib/manifest.ml')
-rw-r--r--lib/manifest.ml114
1 files changed, 57 insertions, 57 deletions
diff --git a/lib/manifest.ml b/lib/manifest.ml
index f987859..17779e9 100644
--- a/lib/manifest.ml
+++ b/lib/manifest.ml
@@ -379,6 +379,63 @@ module Pijul = struct
}
end
+module Kind = struct
+ type t = [
+ | `File of File.t
+ | `Archive of Archive.t
+ | `Git of Git.t
+ | `Darcs of Darcs.t
+ | `Pijul of Pijul.t
+ ]
+ [@@deriving show, eq, qcheck]
+
+ let to_manifest : Input.Kind.t -> t = function
+ | `File f -> `File (File.to_manifest f)
+ | `Archive a -> `Archive (Archive.to_manifest a)
+ | `Git g -> `Git (Git.to_manifest g)
+ | `Darcs d -> `Darcs (Darcs.to_manifest d)
+ | `Pijul p -> `Pijul (Pijul.to_manifest p)
+
+ let of_manifest : t -> Input.Kind.t = function
+ | `File f -> `File (File.of_manifest f)
+ | `Archive a -> `Archive (Archive.of_manifest a)
+ | `Git g -> `Git (Git.of_manifest g)
+ | `Darcs d -> `Darcs (Darcs.of_manifest d)
+ | `Pijul p -> `Pijul (Pijul.of_manifest p)
+
+ let codec : t Util.KDL.codec = {
+ to_kdl = (function
+ | `File f -> File.codec.to_kdl f
+ | `Archive a -> Archive.codec.to_kdl a
+ | `Git g -> Git.codec.to_kdl g
+ | `Darcs d -> Darcs.codec.to_kdl d
+ | `Pijul p -> Pijul.codec.to_kdl p
+ );
+ of_kdl = (fun kdl ->
+ let kind_names = ["file"; "archive"; "git"; "darcs"; "pijul"] in
+ match File.codec.of_kdl kdl,
+ Archive.codec.of_kdl kdl,
+ Git.codec.of_kdl kdl,
+ Darcs.codec.of_kdl kdl,
+ Pijul.codec.of_kdl kdl with
+ | Ok file, Error _, Error _, Error _, Error _ ->
+ Ok (`File file)
+ | Error _, Ok archive, Error _, Error _, Error _ ->
+ Ok (`Archive archive)
+ | Error _, Error _, Ok git, Error _, Error _ ->
+ Ok (`Git git)
+ | Error _, Error _, Error _, Ok darcs, Error _ ->
+ Ok (`Darcs darcs)
+ | Error _, Error _, Error _, Error _, Ok pijul ->
+ Ok (`Pijul pijul)
+ | Error _, Error _, Error _, Error _, Error _ ->
+ Error [`OneRequired kind_names]
+ | _, _, _, _, _ ->
+ Error [`OnlyOneOf kind_names]
+ );
+ }
+end
+
module Hash = struct
type t = {
algorithm: Input.Hash.algorithm; [@default Input.Hash.default_algorithm]
@@ -451,63 +508,6 @@ module Hash = struct
}
end
-module Kind = struct
- type t = [
- | `File of File.t
- | `Archive of Archive.t
- | `Git of Git.t
- | `Darcs of Darcs.t
- | `Pijul of Pijul.t
- ]
- [@@deriving show, eq, qcheck]
-
- let to_manifest : Input.Kind.t -> t = function
- | `File f -> `File (File.to_manifest f)
- | `Archive a -> `Archive (Archive.to_manifest a)
- | `Git g -> `Git (Git.to_manifest g)
- | `Darcs d -> `Darcs (Darcs.to_manifest d)
- | `Pijul p -> `Pijul (Pijul.to_manifest p)
-
- let of_manifest : t -> Input.Kind.t = function
- | `File f -> `File (File.of_manifest f)
- | `Archive a -> `Archive (Archive.of_manifest a)
- | `Git g -> `Git (Git.of_manifest g)
- | `Darcs d -> `Darcs (Darcs.of_manifest d)
- | `Pijul p -> `Pijul (Pijul.of_manifest p)
-
- let codec : t Util.KDL.codec = {
- to_kdl = (function
- | `File f -> File.codec.to_kdl f
- | `Archive a -> Archive.codec.to_kdl a
- | `Git g -> Git.codec.to_kdl g
- | `Darcs d -> Darcs.codec.to_kdl d
- | `Pijul p -> Pijul.codec.to_kdl p
- );
- of_kdl = (fun kdl ->
- let kind_names = ["file"; "archive"; "git"; "darcs"; "pijul"] in
- match File.codec.of_kdl kdl,
- Archive.codec.of_kdl kdl,
- Git.codec.of_kdl kdl,
- Darcs.codec.of_kdl kdl,
- Pijul.codec.of_kdl kdl with
- | Ok file, Error _, Error _, Error _, Error _ ->
- Ok (`File file)
- | Error _, Ok archive, Error _, Error _, Error _ ->
- Ok (`Archive archive)
- | Error _, Error _, Ok git, Error _, Error _ ->
- Ok (`Git git)
- | Error _, Error _, Error _, Ok darcs, Error _ ->
- Ok (`Darcs darcs)
- | Error _, Error _, Error _, Error _, Ok pijul ->
- Ok (`Pijul pijul)
- | Error _, Error _, Error _, Error _, Error _ ->
- Error [`OneRequired kind_names]
- | _, _, _, _, _ ->
- Error [`OnlyOneOf kind_names]
- );
- }
-end
-
module Input' = struct
type t = {
name: Name.t;