From 3a8e8120de2f0ac6188003b81efafa64d5bb6959 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 14 Sep 2021 12:56:26 +0200 Subject: feat(nix/tag): add functions for querying a tag's name and value Both are just trivial wrappers around assertIsTag to make these lookups more ergonomic. This also allows us to demote assertIsTag to an implemtation detail. Change-Id: Ib6ba2a858f4839354a57b660042b418976c4b1d9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3541 Tested-by: BuildkiteCI Reviewed-by: Profpatsch --- nix/tag/default.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'nix') diff --git a/nix/tag/default.nix b/nix/tag/default.nix index 4fe589825848..23f369c2b2d1 100644 --- a/nix/tag/default.nix +++ b/nix/tag/default.nix @@ -24,6 +24,18 @@ let val = null; }; + # Returns the tag name of a given tag attribute set. + # Throws if the tag is invalid. + # + # Type: tag -> string + tagName = tag: (assertIsTag tag).name; + + # Returns the tagged value of a given tag attribute set. + # Throws if the tag is invalid. + # + # Type: tag -> any + tagValue = tag: (assertIsTag tag).val; + # like `verifyTag`, but throws the error message if it is not a tag. assertIsTag = tag: let res = verifyTag tag; in @@ -139,7 +151,8 @@ let in { inherit verifyTag - assertIsTag + tagName + tagValue discr discrDef match -- cgit 1.4.1