Simple Prelude replacement for toy programs
A simple Prelude
replacement, aiming to bring unsafe partial
functions out of scope, and bring in replacements work as suitable
replacements, such as readMaybe
instead of read
, and
head
/tail
that return Maybe
values.
Haddock documentation can be found on GitHub pages.
As a beginner learning Haskell, I do not know enough to evaluate and
choose an existing Prelude
replacement. Instead, I am writing this
in the meantime to get more familiar with what problems I have with the
Prelude
, so I may better choose an existing, tested replacement in
the future.
This is meant for use in toy programs and so on, and should definitely not be used in any real development.
No.
Benchmark results using criterion
can be found in text in
bench.txt, and online on
chuahou.dev.
A short commentary:
- Terrible performance deprovements in
foldr1
,foldl1
,maximum
,minimum
, presumably due to propagation ofMaybe
. - Negligible performance change for
foldr1'
,foldl1'
,maximum'
,minimum'
as they don't do anything extra. - Great performance improvements for
sum
andproduct
using strictfoldl'
in place offoldMap
. - Some small performance degradation for
head
andtail
, as there is someMaybe
overhead, probably. - Larger performance degradation for
last
, as it needs to traverse the list. - Sizable performance degradation for
init
due to a large number offmap
-ed conses. - Lastly, a sizable performance degradation for
(!?)
, since it's just naïve recursion.