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 <mail@profpatsch.de>
This commit is contained in:
sterni 2021-09-14 12:56:26 +02:00
parent 1883159f92
commit 3a8e8120de

View file

@ -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