3 ms·
At first, I thought (like many others) the author was speaking about a syntactic convenience for the template method pattern. Reading various responses and clo
by AdieuToLogic 11y ago
At first, I thought (like many others) the author was speaking about a syntactic convenience for the template method pattern.
Reading various responses and closer inspection of the article made me realize that it seems what is described is more along the lines of a Natural Transformation[1] where the functors are endomorphic[2].
1 - http://www.worldwizzy.com/library/Natural_transformation http://www.worldwizzy.com/library/Natural_transformation
2 - https://en.wikipedia.org/wiki/Endomorphism https://en.wikipedia.org/wiki/Endomorphism
- ShaneWilton 11y agoThe author seems to be getting at something very similar to the notion of "bidirectional programming" [1][2]. It's a concept that's closely related to the indispensable "lens" library in Haskell [3]. [1] http://www.cis.upenn.edu/~bcpierce/papers/lenses-etapsslides.pdf http://www.cis.upenn.edu/~bcpierce/papers/lenses-etapsslides... [2] http://www.janis-voigtlaender.eu/papers/ThreeComplementaryApproachesToBidirectionalProgramming.pdf http://www.janis-voigtlaender.eu/papers/ThreeComplementaryAp... [3] https://github.com/ekmett/lens https://github.com/ekmett/lens
- AdieuToLogic 11y agoWhile I definitely see your point of the concept being closely related to lenses, a key differentiator to me is the incorporation of invoking a functor with the "read part" of a lens and then submitting the result to the "write part." It's almost like a marriage of Applicative Functor[1] with Lens in a squint-your-eyes-and-tilt-your-head kind of way. 1 - https://wiki.haskell.org/Applicative_functor https://wiki.haskell.org/Applicative_functor
- tel 11y agoA natural transformation between endofunctors? How exactly? That's just a family of functions µ : F(x) -> G(x) such that for all (f : x -> y), (F(f);µ == µ;G(f)). I don't see how that's capturing anything interesting here. If µ were a natural isomorphism with inverse µ- then there'd be laws like (F(f) == µ;G(f);µ-), but this exactly involves introducing an inverse so the natural transformation didn't buy much.
- AdieuToLogic 11y agoI thought of endofunctors due to morphisms remaining in the same domain (satisfying the homogeneous domain/codomain requirement of natural transformations), though perhaps a better description would have been to constrain the functors to injective arrows instead.