Commit Graph

3 Commits

Author SHA1 Message Date
Keagan McClelland
c4df2f1dce
fn: reimplement internals of either, add tests 2024-07-10 15:37:27 -07:00
Olaoluwa Osuntokun
f1a38714d4
fn: add additional utility methods for Result[T]
`NewResult` makes it easy to wrap a normal function call in a result
value.

`Err` can be used to check the error case of the result without
unpacking the entire thing.

`AndThen2` allows a caller to compose a function on two results values,
with the closure only executing if both values are non-error.
2024-06-20 15:05:28 -07:00
Oliver Gugger
c95505db1e
fn: add Result type
In this commit, we add a new result type, which is just Either[A, error]. This is useful as we can always pass around/accept a single value. We add an Unpack() method which is the most idiomatic way of handling errors in Go, as we revert back to (A, error) when necessary.
2024-05-29 09:39:39 +02:00