Crate frunk [] [src]

Frunk: generic functional programming toolbelt for Rust

Aims to be a collection of functional programming abstractions implemented in Rust in effective, useful, and idiomatic ways. Examples of things that are included in rust are:

  1. HLists (heterogeneously-typed lists)
  2. Validated (accumulator for Result)
  3. Semigroup
  4. Monoid

Here is a small taste of what Frunk has to offer:

use frunk_core::hlist::*;
use frunk::monoid::*;
use frunk::semigroup::*;
use frunk::validated::*;

// Combining Monoids
let v = vec![Some(1), Some(3)];
assert_eq!(combine_all(&v), Some(4));

// HLists
let h = hlist![1, "hi"];
assert_eq!(h.length(), 2);
let hlist_pat!(a, b) = h;
assert_eq!(a, 1);
assert_eq!(b, "hi");

let h1 = hlist![Some(1), 3.3, 53i64, "hello".to_owned()];
let h2 = hlist![Some(2), 1.2, 1i64, " world".to_owned()];
let h3 = hlist![Some(3), 4.5, 54, "hello world".to_owned()];
assert_eq!(h1.combine(&h2), h3)Run

Links: 1. Source on Github 2. Crates.io page

Reexports

pub use frunk_core::hlist::*;
pub use frunk_core::generic::*;
pub use frunk_derives::*;

Modules

monoid

Module for holding Monoid typeclass definitions and default implementations

semigroup

Module for holding the Semigroup typeclass definition and typeclass instances

validated

Module for holding Validated logic