-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(fp-core): adding functor and HKT into fp-core
- Loading branch information
Showing
41 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
[package] | ||
name = "functional-programming-jargon" | ||
version = "0.1.0" | ||
authors = ["Jason Shin <visualbbasic@gmail.com>"] | ||
edition = "2018" | ||
[workspace] | ||
|
||
[dependencies] | ||
partial_application = "0.1.0" | ||
itertools = "0.8.0" | ||
rats = "0.0.1" | ||
members = [ | ||
"fp-examples", | ||
"fp-core" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "fp-core" | ||
version = "0.1.0" | ||
authors = ["Jason Shin <visualbbasic@gmail.com>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::hkt::HKT; | ||
|
||
pub trait Functor<A, B>: HKT<A, B> { | ||
fn fmap<F>(self, f: F) -> <Self as HKT<A, B>>::Target | ||
where | ||
F: FnOnce(A) -> B; | ||
} | ||
|
||
impl<A, B> Functor<A, B> for Option<A> { | ||
fn fmap<F>(self, f: F) -> Self::Target | ||
where | ||
F: FnOnce(A) -> B, | ||
{ | ||
self.map(f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub trait HKT<A, B> { | ||
type URI; | ||
type Target; | ||
} | ||
|
||
impl<A, B> HKT<A, B> for Option<A> { | ||
type URI = Self; | ||
type Target = Option<B>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod functor; | ||
pub mod hkt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "fp-examples" | ||
version = "0.1.0" | ||
authors = ["Jason Shin <visualbbasic@gmail.com>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
partial_application = "0.1.0" | ||
itertools = "0.8.0" | ||
rats = "0.0.1" | ||
fp-core = { path = "../fp-core" } |
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
src/applicative_example.rs → fp-examples/src/applicative_example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 1 addition & 24 deletions
25
src/functor_example.rs → fp-examples/src/functor_example.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.