úÎ!Œ§iż      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žSafe2finNat natural numbers.Better than GHC's built-in   for some use cases.finż displaying a structure of .explicitShow 0"Z"explicitShow 2 "S (S Z)"finŔ displaying a structure of .finFold .cata [] ('x' :) 2"xx"finConvert  to Á toNatural 00 toNatural 22toNatural $ S $ S $ Z2finConvert Á to  fromNatural 44explicitShow (fromNatural 4)"S (S (S (S Z)))"fin is printed as Á.To see explicit structure, use  or   None&'.1HSUVXf-('finMultiplication.'reflect (snat :: SNat (Mult Nat2 Nat3))6(fin Addition.'reflect (snat :: SNat (Plus Nat1 Nat2))3)finConvert from GHC Â.:kind! FromGHC 7FromGHC 7 :: Nat%= 'S ('S ('S ('S ('S ('S ('S 'Z))))))*finConvert to GHC Â.:kind! ToGHC Nat5ToGHC Nat5 :: GHC.Nat= 5+fin$The induction will be fully inlined.See test/Inspection.hs.-finType family used to implement Ă from Data.Type.Equality module..finConvenience class to get 0.0fin Singleton of .3fin Constructor . dictionary from 0.4finReflect type-level  to the term level.5finAs 4 but with any Ä.6finReify .reify nat3 reflect37finConvert 0 to .snatToNat (snat :: SNat Nat1)18finConvert 0 to Á!snatToNatural (snat :: SNat Nat0)0!snatToNatural (snat :: SNat Nat2)29fin&Decide equality of type-level numbers.(eqNat :: Maybe (Nat3 :~: Plus Nat1 Nat2) Just Refl(eqNat :: Maybe (Nat3 :~: Mult Nat2 Nat2)Nothing:fin&Decide equality of type-level numbers.6decShow (discreteNat :: Dec (Nat3 :~: Plus Nat1 Nat2)) "Yes Refl";fin Induction on ', functor form. Useful for computation.8induction1 (Tagged 0) $ retagMap (+2) :: Tagged Nat3 IntTagged 6<fin Induction on ..Useful in proofs or with GADTs, see source of @.=finSee +.>finUnfold n steps of a general recursion.Note: Always  benchmark". This function may give you both badK properties: a lot of code (increased binary size), and worse performance. For known n ># will unfold recursion, for example > (Ĺ :: Ĺ #) f = f (f (f (fix f))) ?fin  0 + n = n@fin  n + 0 = nAfin  0 * n = 0Bfin  n * 0 = 0Cfin  1 * n = nDfin  n * 1 = n;fin zero casefininduction step<fin zero casefininduction step=fin zero casefininduction step:  !"#$%&'()*+,-./0123456789:;<=>?@ABCD:01278./36459-:<;+,=>('*) &%$#"! ?@ABCDNone &'.12HXfL|LfinFinite numbers: [0..n-1].OfinMultiplicative inverse. Works for L n where n3 is coprime with an argument, i.e. in general when n is prime.$map inverse universe :: [Fin N.Nat5] [0,1,3,2,4];zipWith (*) universe (map inverse universe) :: [Fin N.Nat5] [0,1,1,1,1]Adaptation of Khttps://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integerspseudo-code in WikipediaPfinż displaying a structure of L.explicitShow (0 :: Fin N.Nat1)"Z"explicitShow (2 :: Fin N.Nat3) "S (S Z)"QfinŔ displaying a structure of L.RfinFold L.Sfin Convert to Nat.Tfin Convert from Nat.$fromNat N.nat1 :: Maybe (Fin N.Nat2)Just 1$fromNat N.nat1 :: Maybe (Fin N.Nat1)NothingUfin Convert to Á.ĆfinConvert from any Ç Ä.Vfin All values. [minBound .. maxBound] won't work for L &.universe :: [Fin N.Nat3][0,1,2]WfinLike V but Č."universe1 :: NonEmpty (Fin N.Nat3) 0 :| [1,2]XfinV! which will be fully inlined, if n is known at compile time.inlineUniverse :: [Fin N.Nat3][0,1,2]Yfin(inlineUniverse1 :: NonEmpty (Fin N.Nat3) 0 :| [1,2]ZfinL & is inhabited.[finCounting to one is boring.boring0^fin Append two L s together.6append (Left fin2 :: Either (Fin N.Nat5) (Fin N.Nat4))27append (Right fin2 :: Either (Fin N.Nat5) (Fin N.Nat4))7_fin Inverse of ^..split fin2 :: Either (Fin N.Nat2) (Fin N.Nat3)Right 0.split fin1 :: Either (Fin N.Nat2) (Fin N.Nat3)Left 18map split universe :: [Either (Fin N.Nat2) (Fin N.Nat3)]'[Left 0,Left 1,Right 0,Right 1,Right 2]mfinÉ works only on L n where n is prime.ofinOperations module n.3map fromInteger [0, 1, 2, 3, 4, -5] :: [Fin N.Nat3] [0,1,2,0,1,1]fromInteger 42 :: Fin N.Nat0*** Exception: divide by zero...signum (Z :: Fin N.Nat1)0signum (3 :: Fin N.Nat4)12 + 3 :: Fin N.Nat412 * 3 :: Fin N.Nat42pfinL is printed as Á.To see explicit structure, use P or QLNMOPQRSTUVWXYZ[\]^_`abcdefghiLNMRPQSTUOVXWYZ[\]^_`abcdefghiNone,-.8=>?@ACHUVXW3tfin'Constraint for the class that computes |.ufin'Constraint for the class that computes {.vfinCompute the size from the type.wfinGeneric enumerations. Examples:from ()0 to 0 :: ()() to 0 :: BoolFalsemap to F.universe :: [Bool] [False,True]Qmap (to . (+1) . from) [LT, EQ, GT] :: [Ordering] -- Num Fin is modulo arithmetic [EQ,GT,LT]xfinThe size of an enumeration.yfinConverts a value to its index.zfin*Converts from index to the original value.{finGeneric version of y.|finGeneric version of z.…finĘ ~ +†finË ~ 3‡finĚ ~ 2ˆfin() ~ 1‰finVoid ~ 0 tuvwxyz{| wxyz{u|tvNone&'.1=>?@ASUVXfi4ŠfinTotal order of , less-than-or-Equal-to,  \le .ŒfinAn evidence of n \le m.  zero+succ definition.fin Constructor Š dictionary from Œ.fin \forall n : \mathbb{N}, 0 \le n ‘fin8\forall n\, m : \mathbb{N}, n \le m \to 1 + n \le 1 + m ’fin8\forall n\, m : \mathbb{N}, 1 + n \le 1 + m \to n \le m “fin \forall n : \mathbb{N}, n \le n ”fin4\forall n\, m : \mathbb{N}, n \le m \to n \le 1 + m •fin4\forall n\, m : \mathbb{N}, 1 + n \le m \to n \le m –fin?\forall n\, m : \mathbb{N}, n \le m \to m \le n \to n \equiv m —fin@\forall n\, m\, p : \mathbb{N}, n \le m \to m \le p \to n \le p ˜fin;\forall n\, m : \mathbb{N}, \neg (n \le m) \to 1 + m \le n ™fin;\forall n\, m : \mathbb{N}, n \le m \to \neg (1 + m \le n) leProof :: LEProof Nat2 Nat3LESucc (LESucc LEZero)/leSwap (leSwap' (leProof :: LEProof Nat2 Nat3))LESucc (LESucc (LESucc LEZero))8lePred (leSwap (leSwap' (leProof :: LEProof Nat2 Nat3)))LESucc (LESucc LEZero)šfin Find the Œ n m, i.e. compare numbers.›fin0\forall n\ : \mathbb{N}, n \le 0 \to n \equiv 0 žfinŒ values are unique (not Boring though!).Š‹ŒŽ‘’“”•–—˜™š›Š‹ŒŽš‘“”–—˜™•’›None&'.1=>?@AUVXfxÔ˘finAn evidence of n \le m.  refl+step definition.Ľfin Convert from  zero+succ to  refl+step definition. Inverse of Ś.ŚfinConvert  refl+step to  zero+succ definition. Inverse of Ľ.§fin \forall n : \mathbb{N}, 0 \le n ¨fin8\forall n\, m : \mathbb{N}, n \le m \to 1 + n \le 1 + m Šfin8\forall n\, m : \mathbb{N}, 1 + n \le 1 + m \to n \le m Şfin \forall n : \mathbb{N}, n \le n Ťfin4\forall n\, m : \mathbb{N}, n \le m \to n \le 1 + m Źfin4\forall n\, m : \mathbb{N}, 1 + n \le m \to n \le m ­fin?\forall n\, m : \mathbb{N}, n \le m \to m \le n \to n \equiv m Žfin@\forall n\, m\, p : \mathbb{N}, n \le m \to m \le p \to n \le p Żfin;\forall n\, m : \mathbb{N}, \neg (n \le m) \to 1 + m \le n °fin;\forall n\, m : \mathbb{N}, n \le m \to \neg (1 + m \le n) ąfin Find the ˘ n m, i.e. compare numbers.˛fin0\forall n\ : \mathbb{N}, n \le 0 \to n \equiv 0 ľfin˘ values are unique (not Boring though!).˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛˘Ł¤ĽŚą§¨ŞŤ­ŽŻ°ŹŠ˛None&'.=>?@AHSUVX-ˇfinLess-Than-or. <. Well-founded relation on .GHC can solve this for us!ltProof :: LTProof Nat0 Nat4 LESucc LEZeroltProof :: LTProof Nat2 Nat4LESucc (LESucc (LESucc LEZero))ltProof :: LTProof Nat3 Nat3... ...error......šfin An evidence n < m# which is the same as (1 + n le m).ťfin'\forall n : \mathbb{N}, n < n \to \bot źfin5\forall n\, m : \mathbb{N}, n < m \to m < n \to \bot ˝fin:\forall n\, m\, p : \mathbb{N}, n < m \to m < p \to n < p ˇ¸šşťź˝ˇ¸šşťź˝Í    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ą˘Ł¤ĽŚ‘§¨ŠŞ•–—˜™š›œžŸ Ą˘ŁŚŤŹ­ŽŻ°ą˛ ł´ łľ śˇ¸š şť ź˝ žżŔ¸Á ĂÄ Ĺ ĆǸšȸšÉĘ fin-0.0.3-I7hna9ALStlHUYKviBRVBjData.FinData.Nat Data.Type.Nat Data.Fin.EnumData.Type.Nat.LEData.Type.Nat.LE.ReflStepData.Type.Nat.LT GHC.TypeLitsNatbaseGHC.Real toIntegerZS explicitShowexplicitShowsPreccata toNatural fromNaturalnat0nat1nat2nat3nat4nat5nat6nat7nat8nat9 $fHashableNat $fNFDataNat $fEnumNat $fIntegralNat $fRealNat$fNumNat $fShowNat$fEqNat$fOrdNat $fDataNatNat9Nat8Nat7Nat6Nat5Nat4Nat3Nat2Nat1Nat0MultPlusFromGHCToGHCInlineInductioninlineInduction1EqNatSNatIsnatSNatSZSSwithSNatreflect reflectToNumreify snatToNat snatToNaturaleqNat discreteNat induction1 inductioninlineInduction unfoldedFixproofPlusZeroNproofPlusNZeroproofMultZeroNproofMultNZero proofMultOneN proofMultNOne$fTestEqualityNatSNat$fSNatIS$fSNatIZ$fInlineInductionS$fInlineInductionZ $fShowTagged $fShowSNatFininversetoNatfromNatuniverse universe1inlineUniverseinlineUniverse1absurdboring weakenLeft weakenRightappendsplitfin0fin1fin2fin3fin4fin5fin6fin7fin8fin9 $fHashableFin $fNFDataFin $fEnumFin $fIntegralFin $fRealFin$fNumFin $fShowFin $fBoundedFin$fOrdFin$fEqFinGToGFrom GEnumSizeEnumEnumSizefromtogfromgto $fGFromRepU1 $fGFromRepV1 $fGFromRepM1 $fGFromRep:+: $fGToRepU1 $fGToRepV1 $fGToRepM1 $fGToRep:+: $fEnumEither$fEnumOrdering $fEnumBool$fEnum() $fEnumVoidLEleProofLEProofLEZeroLESucc withLEProofleZeroleSucclePredleReflleStepleStepLleAsymleTransleSwapleSwap'decideLEproofZeroLEZero$fDecidableLEProof $fOrdLEProof $fEqLEProof$fLESm$fLEZm $fShowLEProofLEReflLEStep fromZeroSucc toZeroSuccLTltProofLTProof withLTProof ltReflAbsurd ltSymAbsurdltTrans$fLTnmGHC.Showshow showsPrec GHC.NaturalNaturalghc-prim GHC.TypesData.Type.Equality==GHC.NumNum Data.ProxyProxy unsafeFromNum GHC.ClassesOrdGHC.BaseNonEmptyquot Data.EitherEitherOrderingBool