haskell-nix/hnix

Please, make the statement "Monoid is not []" true

Aperta

#880 aperta il 11 mar 2021

 (5 commenti) (0 reazioni) (0 assegnatari)Nix (116 fork)github user discovery
API breaking refactoringgood first issue

Metriche repository

Star
 (835 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

One of the core stones HNix stumbles on is pretty pervasive String (as exceptions that gather provenance info, and in REPL) and, especially, List being used across the whole project.

The List is famously a one-directionally linked chain structure.

That means that per every cell used there is a cell that holds a pointer. And there is no way to append to list without traverse of the whole list.

Appending x meaning traverse every time, which is doing x^2 actions, so indeed - exponential append.

The most frequent thing the structure builder does is appending.

So, lets look at what actions happen with the Monoid, and most probably replace the List with an efficient Monoid, for example: https://hackage.haskell.org/package/acc

Guida contributor