A small package providing python-flavored Option[T]
and Result[T, E]
types. Fully statically typed.
Option[T]
=Some[T]
|Null
Null
is an Enum with a single member,null
- support for
match
statement:match option: case Some(value): print(value) case Null.Null: ...
Result[T, E]
=Ok[T]
|Err[E]
- support for
match
statement:match result: case Ok(value): print(value) case Err(value): print(value)
- Turn
T | None
intoOption[T]
withfrom_none
- Turn exceptions into
Null
withtry_option
- Turn functions that
return T
/raise E
intoResult[T, E]
withtry_result
CatchResult
context manager to turn arbitrary block of code intoResult