maybe
maybe
Maybe Monad for Crystal
Installation
-
Add the dependency to your
shard.yml
:dependencies: maybe: github: moba1/maybe
-
Run
shards install
Usage
require "maybe"
j = Maybe::Just.new(1)
p j.to_s # ==> Maybe::Just(Int32)(1)
p j.map { |x| x * 2 } # ==> Maybe::Just(Int32)(2)
p j.or_else(3) # ==> Maybe::Just(Int32)(1)
n = Maybe::Nothig(String).new # require type parameter in order to infer type
p n.to_s # ==> Maybe::Nothing(String)
p n.map { |x| x * 2 } # ==> Maybe::Nothing(Int32)
p n.or_else("Nothing!") # ==> Maybe::Just(String)("Nothing!")
Contributing
- Fork it (https://github.com/moba1/maybe/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Yuma Fukuda - creator and maintainer
Repository
maybe
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- over 5 years ago
- April 19, 2019
License
MIT License
Links
Synced at
Sun, 17 Nov 2024 08:45:33 GMT
Languages