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.2@sha256:f77fc15315b9ee670fbee101af154fbe799a3a6b172862c202309a0a79268121,1201

Module documentation for 0.1.0.2

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