type-level-natural-number

Simple type level natural numbers

LTS Haskell 22.41:2.0
Stackage Nightly 2024-11-12:2.0
Latest on Hackage:2.0

See all snapshots type-level-natural-number appears in

BSD-3-Clause licensed by Gregory Crosswhite
Maintained by Gregory Crosswhite
This version can be pinned in stack with:type-level-natural-number-2.0@sha256:d9b757b3244edf511296007cbea1c16d5861f8ba6d131603361d313d4d73ed3c,2554

Module documentation for 2.0

Depends on 1 package(full list with versions):
Used by 1 package in nightly-2024-11-10(full list with versions):

This is a simple implementation of type-level natural numbers that only requires DeriveDataTypeable. Operations requiring more language extensions have been split into a separate package.

The difference between this package and the many others on Hackage implementing type-level naturals is its emphasis on simplicity. It only supports non-negative natural numbers, and only the successor and predicessor operations. It represents natural numbers using a type-level linked list, so it is not intended to be used for representing large numbers. Pre-defined aliases for natural numbers up to 15 are provided.

The code for this package was largely taken from the excellent Vec package; I created this package with the intent of making this functionality more widely available.

Difference from 1.0: Added instances for Typeable, and word synonyms for N0...N15.

Difference from 1.1: Performance enhancements for naturalNumberAsInt. Simplified Show implementation.

Difference from 1.1.1: Gave up on Haskell 2010 compatibility since as of GHC 7.8 manually deriving from Typeable is no longer allowed; now I use DeriveDataTypeable to construct the instances.