clean maybe.nix
This commit is contained in:
parent
22ed581b2d
commit
eea431a912
1 changed files with 1 additions and 22 deletions
|
|
@ -38,32 +38,13 @@ in rec {
|
||||||
assert enfIsMaybe T "isMaybeNone";
|
assert enfIsMaybe T "isMaybeNone";
|
||||||
! T._some;
|
! T._some;
|
||||||
|
|
||||||
# TODO: ensure you check isNone if isSome fails (otherwise it could be another type!)
|
|
||||||
# Unwrap (Monadic Return Operation)
|
|
||||||
# unwrapMaybe = f: g: T:
|
|
||||||
# if isSome T
|
|
||||||
# then f T._value_
|
|
||||||
# else g T._value_;
|
|
||||||
# unwrapSome = unwrapMaybe (v: v);
|
|
||||||
# unwrapNone = f: unwrapMaybe f (v: v);
|
|
||||||
|
|
||||||
# Monadic Bind Operation
|
# Monadic Bind Operation
|
||||||
bindMaybe = f: T:
|
bindMaybe = f: T:
|
||||||
if isSome T
|
if isSome T
|
||||||
then Some (f T._value)
|
then Some (f T._value)
|
||||||
else T;
|
else T;
|
||||||
|
|
||||||
# Conditionals
|
# Utility Functions
|
||||||
# someOr = f: T:
|
|
||||||
# if isSome T
|
|
||||||
# then T
|
|
||||||
# else f T;
|
|
||||||
|
|
||||||
# noneOr = f: T:
|
|
||||||
# if isNone T
|
|
||||||
# then T
|
|
||||||
# else f T;
|
|
||||||
|
|
||||||
boolToMaybe = x:
|
boolToMaybe = x:
|
||||||
if x
|
if x
|
||||||
then Some true
|
then Some true
|
||||||
|
|
@ -73,6 +54,4 @@ in rec {
|
||||||
if x == null
|
if x == null
|
||||||
then None
|
then None
|
||||||
else Some x;
|
else Some x;
|
||||||
|
|
||||||
maybeTobool = isSome;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue