Skip to content

t1mn0/eav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Errors Are Values

CI C++20 License

eav is a C++20 header-only library for error handling, inspired by the philosophies of Rust, Go, and functional programming.

The library provides a Result<T, E> & Option<T> types that help to process errors as values explicitly, without a hidden exception control flow, while maintaining code purity using pipeline syntax in a style typical of functional programming.

Combinators

eav-lib provides ability to chain complex logic into a single, readable flow. With eav-lib, you compose logic using the | (pipe) operator.

Key Combinators

For Result<T,E>:

  • MapOk: transforms the successful value;
  • AndThen: chains another operation that might fail (monadic bind);
  • Filter: validates a value and converts it to an error if criteria aren't met;
  • MapErr: converts error types;
  • OrElse: recovers from an error or provides a fallback value;

For Option<T>:

  • Map: transforms the value if present;
  • AndThen: chains another operation returning an Option;
  • Filter: keeps the value only if it satisfies a predicate;
  • OrElse: provides a fallback Option if the current one is None;

Examples

Install

Since the eav is header-only, you can simply copy the eav folder to your project or use CMake's FetchContent:

include(FetchContent)
FetchContent_Declare(
  eav
  GIT_REPOSITORY https://github.com/t1mn0/eav.git
  GIT_TAG main
)
FetchContent_MakeAvailable(eav)

target_link_libraries(your_project PRIVATE eav)

Refs

Philosophy and design principles:

Combinators and functional pipeline ideas:

About

errors are values

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors