This change extends the API of Control.Foldl.NonEmpty by some of the exports suggested in #209:
Fold1_ pattern synonym
purely
purely_
premap
handles
foldOver
folded1
I created a naive benchmark that compares the execution time of
NonEmpty.map succ
variant that uses Fold
variant that uses FoldM
variant that uses the current definition data Fold1 a b = forall x. Fold1 !(a -> x) !(x -> a -> x) !(x -> b)
imported qualified as Foldl1
variant that uses the alternative definition data Fold1 a b = Fold1 (a -> Fold a b) from #209
imported qualified as L1
Note that the y-axis uses a logarithmic scale.
In this benchmark the current definition of the Fold1 data type clearly performs worse than the alternative definition of Fold1.
The alternative definition of Fold1 performs similar to the Fold(M) variants.
Finally, the Fold* variants all perform worse than NonEmpty.map succ.
Personally, I favor changing the definition of the Fold1 data type and turning the current definition into a pattern synonym. However, in #209 you mentioned you believe
that for most functions the existing definition promotes the greatest code reuse.
Thus, I left the current definition unchanged and added the alternative definition as a pattern synonym.
This change extends the API of
Control.Foldl.NonEmpty
by some of the exports suggested in #209:Fold1_
pattern synonympurely
purely_
premap
handles
foldOver
folded1
I created a naive benchmark that compares the execution time of
NonEmpty.map succ
Fold
FoldM
data Fold1 a b = forall x. Fold1 !(a -> x) !(x -> a -> x) !(x -> b)
imported qualified as
Foldl1
data Fold1 a b = Fold1 (a -> Fold a b)
from #209 imported qualified asL1
Note that the y-axis uses a logarithmic scale.
In this benchmark the current definition of the
Fold1
data type clearly performs worse than the alternative definition ofFold1
. The alternative definition ofFold1
performs similar to theFold(M)
variants. Finally, theFold*
variants all perform worse thanNonEmpty.map succ
.Personally, I favor changing the definition of the
Fold1
data type and turning the current definition into a pattern synonym. However, in #209 you mentioned you believeThus, I left the current definition unchanged and added the alternative definition as a pattern synonym.