modular-arithmetic: A type for integers modulo some constant.

[ bsd3, library, math ] [ Propose Tags ]

A convenient type for working with integers modulo some constant. It saves you from manually wrapping numeric operations all over the place and prevents a range of simple mistakes. Integer Mod 7 is the type of integers (mod 7) backed by Integer. We also have some cute syntax for these types like ℤ/7 for integers modulo 7.

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,, (info)
Change log
Dependencies base (>4.9 && <5), typelits-witnesses (<0.5) [details]
License BSD-3-Clause
Author Tikhon Jelvis <>
Maintainer Tikhon Jelvis <>
Category Math
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by TikhonJelvis at 2023-06-08T23:35:44Z
Distributions NixOS:
Reverse Dependencies 5 direct, 14 indirect [details]
Downloads 9666 total (38 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 2023-06-09 [all 1 reports]

Readme for modular-arithmetic-

[back to package description]

Modular Arithmetic

Hackage package

This package provides a type for integers modulo some constant, usually written as ℤ/n.

Here is a quick example:

>>> 10 * 11 :: ℤ/7

It also works correctly with negative numeric literals:

>>> (-10) * 11 :: ℤ/7

Modular division is an inverse of modular multiplication. It is defined when divisor is coprime to modulus:

>>> 7 `div` 3 :: ℤ/16
>>> 3 * 13 :: ℤ/16