peano: Peano numbers

[ bsd3, data, library, math ] [ Propose Tags ]

Lazy unary natural numbers.

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,
Change log
Dependencies base (>=4.9 && <5) [details]
License BSD-3-Clause
Author M Farkas-Dyck, Andreas Abel
Maintainer Andreas Abel
Category Data, Math
Source repo head: git clone
Uploaded by AndreasAbel at 2023-10-23T09:30:25Z
Distributions Arch:, Fedora:, LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 11 direct, 14 indirect [details]
Downloads 3957 total (97 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-23 [all 1 reports]

Readme for peano-

[back to package description]

peano - Lazy unary natural numbers

This package provides natural numbers in unary notation

data Peano
  = Zero
  | Succ Peano

implementing Num, Ord etc.


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:

    Peano: OK
      450  ns ±  45 ns
    Int:   OK
      136  ms ± 4.1 ms