6 releases
Uses old Rust 2015
0.1.5 | Jun 10, 2018 |
---|---|
0.1.4 | May 26, 2018 |
#2733 in Rust patterns
24KB
336 lines
Category
- Introduction
- Install
- Usage
- Requirement
- Basic function
- Typeclass in rust as trait
- Typeclass impl for std struct and enum of Rust
- Contribution and developing
- Thanks List
- LICENSE
Introduction
KaguyaRs is a TOY functional library of Rust.
In fact, this is just the way I get familiar with Rust. I will try my best to implement as many as utilities. But NEVER try this in production environment UNTIL:
- Someday, I remove TOY in Introduction. OR
- I publish 1.0-stable version.
Key concerns of this library:
- May all the functions in this library are pure IF I CAN.
- Similar as 1, but pure -> lazy
- Base on 1, heavy clone may occur, persistance data structure will be introduced later to achive 4
- Performance. If not necessary
trait object
will be avoided. - Implementation may be ugly and buggy, just feel free to issue it for any ideas.
Install
Add dependency to your Cargo.toml
[dependencies]
kaguya_rs = "*"
Usage
Please refer tests and Docs
Requirement
- toolchain: nightly
- it can be normally used in stable, however feature is required for crate docs, clone repo if you want to use under stable
- rustc version >= 1.26
Basic function
Basic function and its signature provided is listed below, function based on map will be applied later
There are two versions: function and macro
For curry version, it act as a macro. The macro will form a new closure, for example
let f = map(|x| x+1, [1,2,3,4,5]);
assert_eq!(f, [2,3,4,5,6]);
let f2 = map!(|x| x+1)([1,2,3,4,5]); // (Number -> Number) -> [Number] -> [Number]
assert_eq!(f2, [2,3,4,5,6])
For macro version, please refer test for further details as macro can curry automatically depends on the way to invoke macro.
For details, please refer TODO.md.
Typeclass in rust as trait
In Haskell, there are so many useful typeclass such as Monad, Functor, Applicative etc. I will implement as much as typeclass as I can. This can greatly empower ability of Functional Programming in Rust.
Typeclass impl for std struct and enum of Rust
There are some struct and enum that are widely used in Rust, e.g. Vec, HashMap, Option, Result etc. They can be treat as ADT that can impl typeclass of Haskell like Monad. I will implement them to enhance the power of std struct and enum.
Contribution and developing
Feel free to contribute and develop base on this lib. Make sure you MUST follow the constraint of LICENSE.
If you are interested to develop this library together, just make PRs OR send me a email to explain what you want to do for this library as a contributor.
For other questions, please create a new issue for following.
Thanks List
LICENSE
Apache License v2.