ghc-typelits-extra
Additional type-level operations on GHC.TypeLits.Nat
| LTS Haskell 24.28: | 0.4.8 |
| Stackage Nightly 2026-01-18: | 0.5.2 |
| Latest on Hackage: | 0.5.2 |
BSD-2-Clause licensed by Christiaan Baaij
Maintained by [email protected]
This version can be pinned in stack with:
ghc-typelits-extra-0.5.2@sha256:0d04483a660be3987213418316d2bd9c1a3dcb4227df0a0f80c32e98b87f76fe,5640Module documentation for 0.5.2
- GHC
- GHC.TypeLits
- GHC.TypeLits.Extra
- GHC.TypeLits.Extra.Solver
- GHC.TypeLits.Extra
- GHC.TypeLits
Depends on 10 packages(full list with versions):
ghc-typelits-extra
Extra type-level operations on GHC.TypeLits.Nat and a custom solver implemented as a GHC type-checker plugin:
GHC.TypeLits.Extra.Max: type-level maxGHC.TypeLits.Extra.Min: type-level minGHC.TypeLits.Extra.Div: type-level divGHC.TypeLits.Extra.Mod: type-level modGHC.TypeLits.Extra.FLog: type-level equivalent of integerLogBase# .i.e. the exact integer equivalent to “floor (logBase x y)”GHC.TypeLits.Extra.CLog: type-level equivalent of the ceiling of integerLogBase# .i.e. the exact integer equivalent to “ceiling (logBase x y)”- ‘GHC.TypeLits.Extra.Log’: type-level equivalent of <https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-Integer-Logarithms.html#v:integerLogBase-35- integerLogBase#>
where the operation only reduces when “
floor (logBase b x) ~ ceiling (logBase b x)” GHC.TypeLits.Extra.GCD: a type-level gcdGHC.TypeLits.Extra.LCM: a type-level lcm
Changes
Changelog for the ghc-typelits-extra package
0.5.2 December 3rd 2025
- Add
CLogWZ, an extension of ‘CLog’, which returns the additional third argument in case the second argument is zero - Add rewrite rules for
Min,Max,FLog,CLog, andLog
0.5.1 October 21st 2025
- Compatibility with
ghc-typelits-natnormalise0.9.1 release
0.5.0 October 17th 2025
- Add support for GHC 9.14
- Uses https://hackage.haskell.org/package/ghc-tcplugin-api to make supporting new GHC versions easier
- Support for GHC versions older than 8.8 is dropped
0.4.8 March 4th 2025
- Add support for GHC 9.12.1
0.4.7 May 22nd, 2024
- Add support for GHC 9.10.1
- Fix Plugin silently fails when normalizing <= in GHC 9.4+ #50
- Fix faulty lookup for
ModandDivin GHC >= 9.2
0.4.6 October 10th 2023
- Support for GHC-9.8.1
0.4.5 February 20th 2023
- Support for GHC-9.6.0.20230210
0.4.4 October 21st 2022
- Add support for GHC 9.4
0.4.3 June 18th 2021
- Add support for GHC 9.2.0.20210422
0.4.2 January 1st 2021
- Add support for GHC 9.0.1-rc1
0.4.1 November 10 2020
- Reduce
n <=? Max (n + p) ptoTrue
0.4 March 9 2020
Maxshort-circuits on zero, but is stuckness preserving. i.e.Max (0-1) 0reduces to(0-1)- Reduce inside arithmetic equations. e.g.
1 + a ~ Max 0 a + CLog 2 2
0.3.3 February 6th 2020
- Add support for GHC 8.10.1-alpha2
0.3.2 January 18th 2020
0.3.1 August 26th 2019
- Reduce
a <=? Max a btoTrue - Reduce
n ~ (Max a b) => a <=? ntoTrue - Prove
Max (1 + n) 1 ~ (n+1)
0.3 September 14th 2018
- Move
KnownNat2instances for GHC 8.4’sDivandModfromghc-typelits-extratoghc-typelits-knownnat
0.2.6 Julty 10th 2018
- Add support for GHC-8.6.1-alpha1
0.2.5 May 9th 2018
- Add support for ghc-typelits-natnormalise-0.6
0.2.4 January 4th 2018
- Add support for GHC-8.4.1-alpha1
0.2.3 May 15th 2017
- Support GHC 8.2
Max,Min,GCD, andLCMnow have a commutativity property #9- Reduce
GCD 0 xtox#9 - Reduce
GCD 1 xto1#9 - Reduce
GCD x xtox#9 - Reduce
LCM 0 xto0#9 - Reduce
LCM 1 xtox#9 - Reduce
LCM x xtox#9 - Reduce
Max (0-1) 0to0#10 - Reduce
Min (0-1) 0to0 - 1#10 - Fixes bugs:
- Solver turns LCM into GCD #8
- Solver turns Max into Min
0.2.2 January 15th 2017
- Reduce
Min n (n+1)ton - Reduce
Max n (n+1)ton+1 - Reduce cases like
1 <=? Div 18 6toTrue - Add a type-level division that rounds up:
type DivRU n d = Div (n + (d - 1)) d - Add a type-level
divMod:DivMod :: Nat -> Nat -> '(Nat, Nat)
0.2.1 September 29th 2016
- Reduce
Max n nton - Reduce
Min n nton
0.2 August 19th 2016
- New type-level operations:
Max: type-levelmaxMin: type-levelminDiv: type-leveldivMod: type-levelmodFLog: floor of logBaseLog: exact integer logBase (i.e. wherefloor (logBase b x) ~ ceiling (logBase b x)holds)LCM: type-levellcm
- Fixes bugs:
CLog b 1doesn’t reduce to0
0.1.3 July 19th 2016
- Fixes bugs:
- Rounding error in
CLogcalculation
- Rounding error in
0.1.2 July 8th 2016
- Solve KnownNat constraints over CLog and GCD, i.e., KnownNat (CLog 2 4)
0.1.1 January 20th 2016
- Compile on GHC 8.0+
0.1 October 21st 2015
- Initial release