This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent 0d19b846f2
commit aebd570a37
7 changed files with 237 additions and 7 deletions

View File

@@ -14,6 +14,10 @@ proc findMaybeFn*[T, B](fns: seq[T {.nimcall.} -> Maybe[B]], val: T): Maybe[B] =
return res
return Nothing[B]()
proc notNegative*[int](x: Maybe[int]): Maybe[int] =
## Maps nil object to nothing
x.filter(i => i >= 0)
when isMainModule:
echo @[
(x: int) => (if x == 2: Just("foo") else: Nothing[string]()),