Closed kozross closed 6 years ago
Well, here's a rather terrible implementation of under2
via ala
:
under2 :: (Newtype n, Newtype n', o' ~ O n', o ~ O n)
=> (o -> n) -> (n -> n -> n') -> (o -> o -> o')
under2 pa f o0 o1 = ala pa (\p -> uncurry f . bimap p p) (o0, o1)
I do agree though that that paragraph is rather confusing. Suggestions for improving it are very welcome! :)
I took a stab at the docs for ala
: https://github.com/jcristovao/newtype-generics/commit/34328307da691d4734b47a67583e9b3a40f49c50
I hope this is better.
The documentation changes have since been released.
Feel free to reopen if you want to discuss this further! :)
I read the following in the documentation for
ala
:The reason for the signature of the hof is due to
ala
not caring about structure. To illustrate why this is important, another function in this package isunder
. It is not extremely useful;under2
might be more useful (with e.g.,mappend
), but then we already digging the trench of "What aboutunder3
?under4
?". The solution utilized here is to just hand off the "packer" to the hof. That way your structure can be imposed in the hof, whatever you may want it to be (e.g., List, Traversable).However, I am not seeing how you could implement
using either
ala
orala'
. Am I misunderstanding what the documentation means byunder2
, theala
andala'
functions, or both?