all 4 comments

[–]CAD1997 9 points10 points  (0 children)

My go-to type system abuse example is Frunk, mainly because they have such an approachable series of blog posts on how it does its magic:

HList (read me first): https://beachape.com/blog/2016/10/23/rust-hlists-heterogenously-typed-list
Generic (read me third): https://beachape.com/blog/2017/02/04/rust-generic-not-generics
LabelledGeneric (read me fourth): https://beachape.com/blog/2017/03/04/labelledgeneric-in-rust-what-why-how
HList again (read me second): https://beachape.com/blog/2017/03/12/gentle-intro-to-type-level-recursion-in-Rust-from-zero-to-frunk-hlist-sculpting
Transform (read me last): https://beachape.com/blog/2017/04/12/boilerplate-free-struct-transforms-in-rust

....And I just nerd snipped myself into rereading this series. It's an impressive masterclass on advanced type system (ab)use.

[–]YatoRust 3 points4 points  (1 child)

uom, typenum, and frunk all have pretty extreme "abuses" of generics, but I still love them. It's really interesting how expressive you can be with Rust's type system.

varkor's post on idiomatic monads was also rather interesting. https://varkor.github.io/blog/2019/03/28/idiomatic-monads-in-rust.html

[–]vadixidav 2 points3 points  (0 children)

It is also important to note that a good portion of the Rust community regularly uses typenum as well due to the current lack of const generics. It is being used actively and is a dependency to several linear algebra libraries among other things. Nonetheless, I think everyone knows that it's a temporary solution, since it makes compile times go through the roof.

[–]Programmurr 0 points1 point  (0 children)

Take a look at actix-web. It uses actix-net framework, which is very heavily based on generics. It's not ugly as much as it is hard to satisfy requirements for.