At the moment toARec is much slower than just using the Rec constructors, IMO that performance penalty is largely unnecessary.
The way toARec works is this pipeline:
Rec f us
=go=> [Any]
=listArray=> Array Int Any
=ARec=> ARec f us
There's two problems with this:
- because go is recursive, it can't be inlined, even though the length of the list is statically known
- The intermediate list isn't eliminated
As an example, I benchmarked this code:
mkToARec :: Int -> ARec ElField Fields
mkToARec i= toARec (Field i :& Field i :& Field i :& Field i :&
Field i :& Field i :& Field i :& Field i :&
Field i :& Field i :& Field i :& Field i :&
Field i :& Field i :& Field i :& Field 99 :&
RNil)
Here's the relevant part of the core:
https://gist.github.com/Philonous/135480d9016a9b51568a1495dacdf63f
At the moment
toARecis much slower than just using theRecconstructors, IMO that performance penalty is largely unnecessary.The way toARec works is this pipeline:
There's two problems with this:
As an example, I benchmarked this code:
Here's the relevant part of the core:
https://gist.github.com/Philonous/135480d9016a9b51568a1495dacdf63f