Comment

Comment by sfvisser

These patterns might seem abstract and obscure at first, but have proven tremendously powerful in practice to me.

The current project I’m working on in Rust has a big recursive data type with quite some branches and different instantiations of recursive positions. Box/Vec/Option etc.

By parametrizing the enum with a type variable and tying the knot with a type level fixed point combinator gives you back the originally intended data type. But now suddenly you can put annotations in the recursive positions as well, use generic cata/para and other higher level combinators. Fun and powerful stuff!

(The lack of HKT in Rust can be challenging, but it’s mostly easy to work around it)

parent sfvisser 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton