Skip to content

Commit

Permalink
Frunk 0.1.29
Browse files Browse the repository at this point in the history
Core 0.0.16

Derives 0.0.17

frunk 0.1.29

Laws 0.0.7

Bump frunk usage of laws
  • Loading branch information
lloydmeta committed Jun 3, 2017
1 parent 0da793d commit 295e1d1
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frunk"
version = "0.1.28"
version = "0.1.29"
authors = ["Lloyd <[email protected]>"]
description = "Frunk provides developers with a number of functional programming tools like HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid, Semigroup and friends."
license = "MIT"
Expand All @@ -16,12 +16,12 @@ time = "0.1.36"

[dependencies.frunk_core]
path = "core"
version = "0.0.15"
version = "0.0.16"

[dependencies.frunk_derives]
path = "derives"
version = "0.0.16"
version = "0.0.17"

[dev-dependencies.frunk_laws]
path = "laws"
version = "0.0.6"
version = "0.0.7"
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frunk_core"
version = "0.0.15"
version = "0.0.16"
authors = ["Lloyd <[email protected]>"]
description = "Frunk core provides developers with HList and Generic"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions derives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frunk_derives"
version = "0.0.16"
version = "0.0.17"
authors = ["Lloyd <[email protected]>"]
description = "frunk_derives contains the custom derivations for certain traits in Frunk."
license = "MIT"
Expand All @@ -20,4 +20,4 @@ quote = "0.3.15"

[dependencies.frunk_core]
path = "../core"
version = "0.0.15"
version = "0.0.16"
6 changes: 3 additions & 3 deletions laws/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "frunk_laws"
version = "0.0.6"
version = "0.0.7"
authors = ["Lloyd <[email protected]>"]
description = "frunk_laws contains laws for algebras declared in Frunk."
license = "MIT"
Expand All @@ -13,7 +13,7 @@ travis-ci = { repository = "lloydmeta/frunk" }

[dependencies.frunk]
path = ".."
version = "0.1.28"
version = "0.1.29"

[dependencies]
quickcheck = "0.3"
quickcheck = "0.4.1"
27 changes: 27 additions & 0 deletions src/functor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Holds declarations for some variatiosn of F
//!
//! One of the goals of this is to allow for both
//! by reference and by value mapping based purely on
//! the kind of argument taken by the function argument
use kind::*;

pub trait Functor<A, B>
where Self: Kind<A>,
Self: Kind<B>
{
fn map<F>(self, f: F) -> <Self as Kind<B>>::Repr
where F: FnOnce(A) -> B;
}


impl <A, B> Functor<A, B> for Option<A> where Option<A>: Kind<B>{

fn map<F>(self, f: F) -> <Self as Kind<B>>::Repr
where F: FnOnce(A) -> B {
match self {
Some(v) => Some(f(v)),
None => None
}
}
}
3 changes: 3 additions & 0 deletions src/kind.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub trait Kind {}

impl <A> Kind for Option<A> {}
18 changes: 18 additions & 0 deletions tests/scratchpad.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::sync::Mutex;

struct IntHolder(i32);

fn plus_one(wrapped: &Mutex<IntHolder>) -> Option<i32> {
match wrapped.lock() {
Ok(ref data) => Some(data.0),
_ => None,
}.map(|data| {
data + 1
})
}

fn main() {
let holder_mutx = Mutex::new(IntHolder(420));
let insides_incremented = plus_one(&holder_mutx);
println!("{:?}", insides_incremented)
}

0 comments on commit 295e1d1

Please sign in to comment.