Higher: Favourite Haskell type classes for Rust (2023)

https://news.ycombinator.com/rss Hits: 3
Summary

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. s and IO monads that wrap futures that can fail. Most of Foldable , with the ambition of some of Traversable to follow. (It's always traverse .) , with the ambition of some of to follow. (It's always .) Rings and algebras, just in case. Not necessarily a lot of good documentation, but like any good Haskell programmer you should be able to immediately infer every function's purpose from its type signature. What are your intentions with this? I wrote this for two reasons: first, to see if it w...

First seen: 2025-06-24 18:12

Last seen: 2025-06-24 20:13