clean nt.nix

This commit is contained in:
Emile Clark-Boman 2026-01-27 11:16:33 +10:00
parent e9496d1994
commit 349d451fa0

View file

@ -27,7 +27,7 @@
in rec { in rec {
openNT = openTrapdoor ntTrapdoorKey; openNT = openTrapdoor ntTrapdoorKey;
# check if a value is an nt type/class # check if a value is NixTypes compatible
isNT = T: isNT = T:
openNT T openNT T
|> mapMaybe (content: attrNames content |> contains ["sig" "derive" "ops" "req"]) |> mapMaybe (content: attrNames content |> contains ["sig" "derive" "ops" "req"])
@ -54,9 +54,8 @@ in rec {
&& content.instance == true) && content.instance == true)
|> isSome; |> isSome;
# XXX: TODO: Some of these functions are unsafe but aren't marked as unsafe # XXX: TODO: Implement isomorphisms between types especially
# XXX: TODO: because they WILL BE safe once I implement isomorphisms between types # XXX: TODO: implicit isomorphism from nix primitives to NT types.
# XXX: TODO: especially implicit isomorphism from nix primitives to NT types
impls = type: T: impls = type: T:
assert enfIsNT T "nt.impls"; assert enfIsNT T "nt.impls";
@ -81,11 +80,9 @@ in rec {
then x then x
else typeSig x; else typeSig x;
# XXX: TODO: move ntTrapdoorKey to nt.nix
ntTrapdoorKey = mkTrapdoorKey "nt"; ntTrapdoorKey = mkTrapdoorKey "nt";
# TODO: rename enfIsType -> enfIsPrimitive enfIsPrimitive = type: value: msg: let
enfIsType = type: value: msg: let
got = typeOf value; got = typeOf value;
in in
got == type || throw "${msg}: expected primitive nix type \"${type}\" but got \"${got}\""; got == type || throw "${msg}: expected primitive nix type \"${type}\" but got \"${got}\"";