factory 0.2.0.2 → 0.2.0.3
raw patch · 3 files changed
+7/−5 lines, 3 files
Files
- changelog +2/−0
- factory.cabal +1/−1
- src/Factory/Math/Radix.hs +4/−4
changelog view
@@ -50,3 +50,5 @@ * Made 'Factory.Data.Interval.getLength' private. * Added 'Factory.Data.Interval.mkBounded'. * Generalised "Factory.Math.Statistics" to accept any 'Data.Foldable.Foldable' 'Functor', rather than merely lists.+0.2.0.3+ * Added "class Show" to several contexts, for migration to 'ghc-7.4'.
factory.cabal view
@@ -1,6 +1,6 @@ --Package-properties Name: factory-Version: 0.2.0.2+Version: 0.2.0.3 Cabal-Version: >= 1.6 Copyright: (C) 2011 Dr. Alistair Ward License: GPL
src/Factory/Math/Radix.hs view
@@ -58,7 +58,7 @@ * The conversion to 'Char' can only succeed where printable and intelligible characters exist to represent all digits in the chosen base; which in practice means @(-36 <= base <= 36)@. -}-toBase :: (Integral base, Data.Array.IArray.Ix decimal, Integral decimal) => base -> decimal -> String+toBase :: (Data.Array.IArray.Ix decimal, Integral base, Integral decimal, Show decimal, Show base) => base -> decimal -> String toBase 10 decimal = show decimal --Base unchanged. toBase _ 0 = "0" --Zero has the same representation in any base. toBase base decimal@@ -74,7 +74,7 @@ where (quotient, remainder) = n `quotRem` fromIntegral base - toDigit :: (Data.Array.IArray.Ix i, Integral i) => i -> Char+ toDigit :: (Data.Array.IArray.Ix i, Integral i, Show i) => i -> Char toDigit n | n >&< encodes = encodes ! n | otherwise = error $ "Factory.Math.Radix.toBase.toDigit:\tno suitable character-representation for integer " ++ show n@@ -88,7 +88,7 @@ * Both negative numbers and negative bases are permissible. -}-fromBase :: (Integral base, Integral decimal, Read decimal) => base -> String -> decimal+fromBase :: (Integral base, Integral decimal, Read decimal, Show base) => base -> String -> decimal fromBase 10 s = read s --Base unchanged. fromBase _ "0" = 0 --Zero has the same representation in any base. fromBase base s@@ -108,7 +108,7 @@ * <http://en.wikipedia.org/wiki/Digit_sum>. -}-digitSum :: (Integral base, Data.Array.IArray.Ix decimal, Integral decimal) => base -> decimal -> decimal+digitSum :: (Data.Array.IArray.Ix decimal, Integral base, Integral decimal, Show decimal) => base -> decimal -> decimal digitSum 10 = fromIntegral . foldr ((+) . Data.Char.digitToInt) 0 . show digitSum base = sum . Data.Maybe.mapMaybe (`lookup` decodes) . toBase base