Open treeowl opened 1 year ago
I'm fine with that. Couldn't we also just use coerce f
though?
Maybe. I expect that'll work fine for relatively recent GHC versions, but things were a bit wonky in 7.10 and 8.0, IIRC. Maybe not too wonky for what we're doing here.
Another good option might be to drop any GHC versions where we can't just use coerce
. But doesn't this package have a tradition of trying not to be GHC specific?
But doesn't this package have a tradition of trying not to be GHC specific?
IIRC yes (although I can't find any comment on that rn), but IMO that's a lost cause. GHC is de facto the only Haskell compiler and I'm pretty sure that most packages (including deepseq
and indexed-traversable
, which this package depends on) don't work with other compilers anyway.
We have a lot of
f . unDown
getting passed to higher-order functions that can't inline. In situations where GHC doesn't know thatf
has arity at least 1, the RTS will allocate a closure through which to callf
. That's not nice. We should borrow a trick fromprofunctors
:Then we can write
Down #. f
to coerce it nicely. The exact definitions inprofunctors
are carefully arranged to work around some weirdness inCoercible
solving back in 7.10 and (IIRC) 8.0.Then we can write things like
We'll also want to implement
mapWithKey
andmapWithKey'
using coercions.