polix.result
Tagged map result type for success/error handling.
Provides a simple alternative to monadic error handling using plain data structures. Results are maps with either :ok or :error keys.
bind
(bind result f)Applies f to value if ok (f must return a result), returns error unchanged.
error
(error error-map)Wraps an error map as an error result.
error?
(error? result)Returns true if result is an error.
map-ok
(map-ok result f)Applies f to the value if result is ok, returns error unchanged.
ok
(ok value)Wraps a value as a success result.
ok?
(ok? result)Returns true if result is a success.
sequence-results
(sequence-results results)Converts a seq of results into a result of seq. Fails on first error.
unwrap
(unwrap result)Extracts value from success, or error-map from error.