Tech News
← Back to articles

Higher: Favourite Haskell type classes for Rust (2023)

read original related products more articles

higher

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:

A set of fine grained traits ( Functor , Pure , Apply , Bind , Applicative and Monad ) for functors, applicatives and monads, inspired by PureScript and Scala's Cats.

, , , , and ) for functors, applicatives and monads, inspired by PureScript and Scala's Cats. Bifunctors, contravariant functors and profunctors, for completeness.

The 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.

macro for Haskell style do notation. I'd have preferred to call it or but unfortunately those are reserved keywords, even for macros. Derive macros for Functor and Bifunctor .

and . Semigroups and monoids, because Rust's Add isn't quite a semigroup so Add + Default isn't quite a monoid.

isn't quite a semigroup so isn't quite a monoid. Effect monads that wrap standard Future s and IO monads that wrap futures that can fail.

... continue reading