fix enfIsMaybe
it never actually checked isMaybe...
This commit is contained in:
parent
349d451fa0
commit
87ab7f7ede
1 changed files with 3 additions and 6 deletions
|
|
@ -17,8 +17,8 @@ in rec {
|
||||||
Some = Maybe true;
|
Some = Maybe true;
|
||||||
None = Maybe false null;
|
None = Maybe false null;
|
||||||
|
|
||||||
# Pattern Matching (unsafe and safe variants)
|
# Type Checking
|
||||||
isMaybe = T: attrNames T == ["_some" "_value"];
|
isMaybe = T: isAttrs T && attrNames T == ["_some" "_value"];
|
||||||
enfIsMaybe = T: msg: let
|
enfIsMaybe = T: msg: let
|
||||||
throw' = got: throw "${msg}: expected naive type Maybe but got ${got}";
|
throw' = got: throw "${msg}: expected naive type Maybe but got ${got}";
|
||||||
attrs =
|
attrs =
|
||||||
|
|
@ -27,12 +27,9 @@ in rec {
|
||||||
|> concatStringsSep ", ";
|
|> concatStringsSep ", ";
|
||||||
in
|
in
|
||||||
if isAttrs T
|
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}\"";
|
else throw' "value \"${toString T}\" of primitive type \"${typeOf T}\"";
|
||||||
|
|
||||||
# isSome = T: isMaybe T && T._some;
|
|
||||||
# isNone = T: isMaybe T && ! T._some;
|
|
||||||
|
|
||||||
isSome = T:
|
isSome = T:
|
||||||
assert enfIsMaybe T "isMaybeSome";
|
assert enfIsMaybe T "isMaybeSome";
|
||||||
T._some;
|
T._some;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue