@hackage peano0.1.1.0
Peano numbers
Categories
License
BSD-3-Clause
Maintainer
Andreas Abel
Links
Versions
Installation
Tested Compilers
Dependencies (1)
Dependents (13)
@hackage/Fin, @hackage/clist, @hackage/VecN, @hackage/rv, @hackage/natural-induction, @hackage/Agda, Show all…
peano - Lazy unary natural numbers
This package provides natural numbers in unary notation
data Peano
= Zero
| Succ Peano
implementing Num, Ord etc.
Purpose
One application is to check whether the length of a (potentially long) list is greater than a (small) number.
E.g., without optimization (-O 0),
genericLength (replicate (10 ^ 6) True) >= (5 :: Peano)
outperforms the same test for 5 :: Int by a factor of 10⁵, see benchmark:
length
Peano: OK
450 ns ± 45 ns
Int: OK
136 ms ± 4.1 ms