fin: Nat and Fin: peano naturals and finite numbers

[ bsd3, data, dependent-types, library, math, singletons ] [ Propose Tags ] [ Report a vulnerability ]

This package provides two simple types, and some tools to work with them. Also on type level as DataKinds.

-- Peano naturals
data Nat = Z | S Nat

-- Finite naturals
data Fin (n :: Nat) where
    Z :: Fin ('S n)
    S :: Fin n -> Fin ('Nat.S n)

vec implements length-indexed (sized) lists using this package for indexes.

The Data.Fin.Enum module let's work generically with enumerations.

See Hasochism: the pleasure and pain of dependently typed haskell programming by Sam Lindley and Conor McBride for answers to how and why. Read APLicative Programming with Naperian Functors by Jeremy Gibbons for (not so) different ones.

Similar packages

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0, 0.0.1, 0.0.2, 0.0.3, 0.1, 0.1.1, 0.2, 0.2.1, 0.3, 0.3.1
Change log ChangeLog.md
Dependencies base (>=4.12.0.0 && <4.21), boring (>=0.2.2 && <0.3), dec (>=0.0.6 && <0.1), deepseq (>=1.4.4.0 && <1.6), hashable (>=1.4.4.0 && <1.5 || >=1.5.0.0 && <1.6), QuickCheck (>=2.14.2 && <2.16), some (>=1.0.6 && <1.1), universe-base (>=1.1.4 && <1.2) [details]
Tested with ghc ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1
License BSD-3-Clause
Copyright (c) 2017-2021 Oleg Grenrus
Author Oleg Grenrus <oleg.grenrus@iki.fi>
Maintainer Oleg.Grenrus <oleg.grenrus@iki.fi>
Revised Revision 1 made by phadej at 2024-08-24T21:13:19Z
Category Data, Dependent Types, Singletons, Math
Home page https://github.com/phadej/vec
Bug tracker https://github.com/phadej/vec/issues
Source repo head: git clone https://github.com/phadej/vec.git(fin)
Uploaded by phadej at 2024-06-08T14:36:14Z
Distributions Arch:0.3, LTSHaskell:0.3, NixOS:0.3, Stackage:0.3.1
Reverse Dependencies 14 direct, 7873 indirect [details]
Downloads 12870 total (198 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-06-08 [all 1 reports]