Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.11 KB

README.md

File metadata and controls

47 lines (33 loc) · 1.11 KB

Funs

License Join the chat at https://gitter.im/ZizhengTai/funs

Funs is a functional programming library for C++. It is currently only a proof of concept, but is under active development.

Examples

std::vector<int> v1{1, 2, 3};

auto v2 = on(v1)
    .map([](int x) { return x * x; })
    .flatMap([](int x) {
        auto s = std::to_string(x) + "!";
        return std::vector<std::string>{s, s};
    })
    .val();

// v2 == std::vector<std::string>{"1!", "1!", "4!", "4!", "9!", "9!"}

Typeclasses

  • Functor (map)
  • Apply (ap)
  • Applicative (pure)
  • Monad (flatMap flatten)
  • Foldable (foldLeft foldRight)
  • Traverse (traverse)

Default Implementations

  • funs::Id
  • std::list
  • std::vector
  • std::unique_ptr
  • std::shared_ptr

Related Projects

Funs is inspired by Cats.

License

This project is licensed under the MIT license. See the LICENSE file for details.