peano: Peano numbers

[ bsd3, data, library, math ] [ Propose Tags ] [ Report a vulnerability ]

Lazy unary natural numbers.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5) [details]
Tested with ghc ==9.8.1, ghc ==9.6.3, ghc ==9.4.7, ghc ==9.2.8, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4, ghc ==8.2.2, ghc ==8.0.2
License BSD-3-Clause
Author M Farkas-Dyck, Andreas Abel
Maintainer Andreas Abel
Category Data, Math
Source repo head: git clone https://github.com/andreasabel/peano.hs
Uploaded by AndreasAbel at 2023-10-23T09:30:25Z
Distributions Arch:0.1.0.1, Fedora:0.1.0.2, LTSHaskell:0.1.0.2, NixOS:0.1.0.2, Stackage:0.1.0.2
Reverse Dependencies 11 direct, 14 indirect [details]
Downloads 4395 total (135 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-0.1.0.2

[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.

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