Crates.io | higher |
lib.rs | higher |
version | 0.2.0 |
source | src |
created_at | 2019-02-26 15:53:47.595165 |
updated_at | 2023-01-18 22:09:51.514661 |
description | Functors, Applicatives, Monads and other bad ideas |
homepage | |
repository | https://github.com/bodil/higher |
max_upload_size | |
id | 117391 |
size | 47,131 |
The functor hierarchy and other terrible ideas for Rust.
Yes, this gives you generalisable monads in Rust. No, they're not very nice compared to Haskell,
because Rust's functions aren't quite as first class from the type system's perspective as you might
like them to be, type constraints in trait implementations can be a serious headache when you want
to implement, say, Functor
for HashSet
, and the type system can be particularly obtuse at times
and need a lot of additional and extremely verbose guidance to get the type inference right, but
they exist now.
What you get from this:
Functor
, Pure
, Apply
, Bind
, Applicative
and Monad
) for
functors, applicatives and monads, inspired by
PureScript and Scala's
Cats.run!
macro for Haskell style do notation. I'd have preferred to call it do!
or for!
but unfortunately those are reserved keywords, even for macros.Functor
and Bifunctor
.Add
isn't quite a semigroup so Add + Default
isn't
quite a monoid.Future
s and IO monads that wrap futures that can fail.Foldable
, with the ambition of some of Traversable
to follow. (It's always
traverse
.)I wrote this for two reasons: first, to see if it was even possible, and second, as a shitpost with some extremely elaborate type signatures. If you think this is actually useful (and I'm mildly horrified to find that I'm starting to think it might be), you may wish to step up to help maintain it, because I doubt I'll keep giving it much attention once the novelty wears off.
Copyright 2019 Bodil Stokke
This software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.