From 87ab7f7ede7750206196ad1ddb41b29b5e370044 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 27 Jan 2026 11:22:37 +1000 Subject: [PATCH] fix enfIsMaybe it never actually checked isMaybe... --- nt/primitives/bootstrap/maybe.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nt/primitives/bootstrap/maybe.nix b/nt/primitives/bootstrap/maybe.nix index 0833256..0bf0dbe 100644 --- a/nt/primitives/bootstrap/maybe.nix +++ b/nt/primitives/bootstrap/maybe.nix @@ -17,8 +17,8 @@ in rec { Some = Maybe true; None = Maybe false null; - # Pattern Matching (unsafe and safe variants) - isMaybe = T: attrNames T == ["_some" "_value"]; + # Type Checking + isMaybe = T: isAttrs T && attrNames T == ["_some" "_value"]; enfIsMaybe = T: msg: let throw' = got: throw "${msg}: expected naive type Maybe but got ${got}"; attrs = @@ -27,12 +27,9 @@ in rec { |> concatStringsSep ", "; in if isAttrs T - then throw' "attribute set with structure [${attrs}]" + then isMaybe T || throw' "attribute set with structure [${attrs}]" else throw' "value \"${toString T}\" of primitive type \"${typeOf T}\""; - # isSome = T: isMaybe T && T._some; - # isNone = T: isMaybe T && ! T._some; - isSome = T: assert enfIsMaybe T "isMaybeSome"; T._some;