fix enfIsMaybe

it never actually checked isMaybe...
This commit is contained in:
Emile Clark-Boman 2026-01-27 11:22:37 +10:00
parent 349d451fa0
commit 87ab7f7ede

View file

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