2 ms·
I think invertible functions and groups are sadly missing from the current functional programming paradigm. Two ideas that I would love to see fleshed out: 1.
by js8 11y ago
I think invertible functions and groups are sadly missing from the current functional programming paradigm. Two ideas that I would love to see fleshed out:
1. If compiler would know which function is invertible, it could automatically build inverses of composed functions. And for instance, you could pattern match on a function argument, and it would automatically do the inversion for you!
2. Knowing that some operator is a group operator could lead to efficient optimizations. Consider a collection over which you calculate a folded value, where the folding is a group operator. Then knowing that, you could use group element inverse to recalculate the value when the collection changes, instead of recalculating it over the whole collection. Example: You need to keep a sum of list of numbers. Since addition is group operator, removing elements could cause the sum to be recalculated via subtraction of the single element.
- dllthomas 11y agoThis is explored some in Haskell in a couple places. One I remember off the top of my head: https://hackage.haskell.org/package/lens-4.13/docs/Control-Lens-Iso.html#g:2 https://hackage.haskell.org/package/lens-4.13/docs/Control-L...