BSD-3-Clause licensed by M Farkas-Dyck, Andreas Abel
Maintained by Andreas Abel
This version can be pinned in stack with:peano-0.1.0.3@sha256:97ee075fd743b5b63ae22d205f20f06a0f8dbd1157e7e04628b30ee4e32ad197,1249

Module documentation for 0.1.0.3

Depends on 1 package(full list with versions):
Used by 2 packages in nightly-2025-09-03(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.

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

Changes

0.1.0.3

Andreas Abel, 2025-09-02

  • Remove obsolete deriving Typeable.
  • Tested with GHC 8.0 - 9.14.1 alpha1.

0.1.0.2

Andreas Abel, 2023-10-23

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

0.1.0.1

Matthew Farkas Dyck, 2015-03-27

0.1.0.0

Matthew Farkas Dyck, 2015-03-27