BSD-3-Clause licensed by M Farkas-Dyck, Andreas Abel
Maintained by Andreas Abel
This version can be pinned in stack with:peano-,1201

Module documentation for

Depends on 1 package(full list with versions):
Used by 2 packages in nightly-2023-12-09(full list with versions):

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


Andreas Abel, 2023-10-23

  • Added benchmark for “genericLength _ >=”.
  • Changed license to BSD 3-clause.
  • Tested with GHC 8.0 - 9.8.1.

Matthew Farkas Dyck, 2015-03-27

Matthew Farkas Dyck, 2015-03-27