type-level-natural-number 1.1 → 1.1.1
raw patch · 3 files changed
+27/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- LICENSE +1/−0
- TypeLevel/NaturalNumber.hs +11/−2
- type-level-natural-number.cabal +15/−3
LICENSE view
@@ -1,5 +1,6 @@ Copyright (c) 2008, Scott E. Dillard Copyright (c) 2010, Gregory M. Crosswhite+Copyright (c) 2012, Claude Heiland-Allen All rights reserved. Redistribution and use in source and binary forms, with or without modification,
TypeLevel/NaturalNumber.hs view
@@ -71,12 +71,21 @@ instance NaturalNumber Zero where naturalNumberAsInt _ = 0 instance NaturalNumber n => NaturalNumber (SuccessorTo n) where- naturalNumberAsInt x = 1 + naturalNumberAsInt (predecessorOf x)+ -- performance enhancing hoop jumping:+ -- this convinces GHC that the function is constant+ -- and so doesn't need to be recomputed every time+ -- which gives a huge performance boost if used a lot+ naturalNumberAsInt = self+ where+ self = const k+ k = (1 +) $! naturalNumberAsInt (predecessorOf (undefined `asTypeIn` self))+ asTypeIn :: a -> (a -> b) -> a+ asTypeIn = const instance Show Zero where show _ = "0" instance NaturalNumber n => Show (SuccessorTo n) where- show = show . (+1) . naturalNumberAsInt . predecessorOf+ show = show . naturalNumberAsInt instance Eq Zero where (==) _ _ = True
type-level-natural-number.cabal view
@@ -1,5 +1,5 @@ Name: type-level-natural-number-Version: 1.1+Version: 1.1.1 License: BSD3 License-file: LICENSE Author: Gregory Crosswhite@@ -11,7 +11,7 @@ non-Haskell 2010 language extensions have been split into a separate package. .- The difference between this package and the many+ The difference between this package and the many others on Hackage implementing type-level naturals is its emphasis on simplicity. It only supports non-negative natural numbers, and only@@ -28,7 +28,10 @@ . Difference from 1.0: Added instances for Typeable, and word synonyms for N0...N15.-Cabal-version: >=1.2.3+ .+ Difference from 1.1: Performance enhancements for+ naturalNumberAsInt. Simplified Show implementation.+Cabal-version: >=1.6 Build-type: Simple Category: Type System,Data @@ -36,3 +39,12 @@ Build-depends: base >= 3 && < 5 Exposed-modules: TypeLevel.NaturalNumber Extensions: EmptyDataDecls++source-repository head+ type: git+ location: git://github.com/gcross/type-level-natural-number.git++source-repository this+ type: git+ location: git://github.com/gcross/type-level-natural-number.git+ tag: 1.1.1