BSD-3-Clause licensed by Oleg Grenrus
Maintained by Oleg.Grenrus
This version can be pinned in stack with:fin-0.3@sha256:aea5c07df40d1130a125a631799241f55b06a1791ea1be5ecfc6713a2367b1ac,3999

Module documentation for 0.3

Used by 3 packages in nightly-2024-04-22(full list with versions):

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



  • Remove Data.Fin.Enum module. It didn’t work as well as hoped.
  • Add EqP and OrdP instances.
  • Add GShow Fin instance.


  • Add boring instances
  • Explicitly implement >= and > for Nat.
  • <=, >= and min for Nat are lazier
  • Add NFData (SNat n) instance
  • Add GEq, GCompare, GNFData, GShow (from some package) instances for SNat.


  • SNat is now what was called InlineInduction. To migrate code from fin-0.1 to fin-0.2 it’s often enough to replace InlineInduction with SNatI, and inlineInduction with induction.
  • Explicitly mark all modules as Safe or Trustworthy.


  • Add universe-base Universe and Finite instances


  • Add isMin and isMax
  • Add mirror, weakenRight1 and weakenLeft1
  • Add Mult2 and DivMod2
  • Explicitly derive Typeable SNat and Typeable LEProof
  • Derive Typeable for Z and S on GHC-7.8 explicitly
  • Add QuickCheck instances for Nat and Fin


  • Rename Fin constructors to FZ and FS. Now you can have both Nat and Fin imported unqualified in a single module.


  • Add Data.Type.Nat.LE, Data.Type.Nat.LT and Data.Type.Nat.LE.ReflStep modules
  • Add withSNat and discreteNat


  • In Fin add: append and split
  • Add (Enum a, Enum b) => Enum (Either a b) instance


  • GHC-8.4.1 / base-4.11 support


  • First version. Released on an unsuspecting world.