úÎ!ت     (c) 2017-2019 Andrew LelechenkoMIT/Andrew Lelechenko <andrew.lelechenko@gmail.com>None .7FH_ksmodThis data type represents  Bhttps://en.wikipedia.org/wiki/Modular_arithmetic#Integers_modulo_nintegers modulo m", equipped with useful instances.For example, 3 :: T 10 stands for the class of integers congruent to 3 modulo 10: &"17, "7, 3, 13, 23 &:set -XDataKinds3 + 8 :: Mod 102(1 `modulo` 10) -- because 3 + 8 = 11 "a 1 (mod 10)Warning:$ division by residue, which is not  .https://en.wikipedia.org/wiki/Coprime_integerscoprime with the modulo, throws . Consider using  for non-prime moduli.mod[The canonical representative of the residue class, always between 0 and m - 1 inclusively.modIf an argument is  .https://en.wikipedia.org/wiki/Coprime_integerscoprimeA with the modulo, return its modular inverse. Otherwise return .:set -XDataKindsinvertMod 3 :: Mod 107Just (7 `modulo` 10) -- because 3 * 7 = 21 "a 1 (mod 10)invertMod 4 :: Mod 10+Nothing -- because 4 and 10 are not coprimemodDrop-in replacement for K with much better performance. Negative powers are allowed, but may throw , if an argument is not  .https://en.wikipedia.org/wiki/Coprime_integerscoprime with the modulo.Building with -O triggers a rewrite rule  = .:set -XDataKinds3 ^% 4 :: Mod 102(1 `modulo` 10) -- because 3 ^ 4 = 81 "a 1 (mod 10)3 ^% (-1) :: Mod 102(7 `modulo` 10) -- because 3 * 7 = 21 "a 1 (mod 10)4 ^% (-1) :: Mod 10B(*** Exception: divide by zero -- because 4 and 10 are not coprimemod%See the warning about division above.mod%See the warning about division above.mod%See the warning about division above.mod%See the warning about division above.8     "mod-0.1.0.0-6moGfkZDtlT9FoH4mrvZjeData.ModModunMod invertMod^% $fFieldMod$fEuclideanMod$fGcdDomainMod$fFractionalMod $fRingMod $fSemiringMod$fNumMod $fBoundedMod $fEnumMod $fShowMod $fNFDataMod$fEqMod$fOrdMod $fGenericModbaseGHC.Exception.Type DivideByZero GHC.MaybeNothingGHC.Real^