data-standards 0.1.0.0 → 0.1.0.1
raw patch · 6 files changed
+52/−42 lines, 6 files
Files
- ChangeLog.md +8/−0
- Data/Standards/ISO/Country/Primary.hs +7/−8
- Data/Standards/ISO/Country/Primary/Alpha2.hs +2/−2
- Data/Standards/ISO/Country/Primary/Alpha3.hs +2/−2
- Data/Standards/ISO/Country/Primary/Numeric.hs +24/−21
- data-standards.cabal +9/−9
ChangeLog.md view
@@ -1,5 +1,13 @@ # Revision history for data-standards +## 0.1.0.1++* "Data.Standards.ISO.Country.Primary" now reexports the types unqualified+* All ISO 3166-1 code types now have 'Ord' instances+* 'enumFromThen' and 'enumFromThenTo' over 'Numeric' no longer throw an error+ if the max bound was included in the sequence+* Updated doumentation to reflect new name for Eswatini (SZ/SWZ/748)+ ## 0.1.0.0 -- 2018-07-06 * ISO 3166-1, in all three variants (alpha-2, alpha-3, and numeric)
Data/Standards/ISO/Country/Primary.hs view
@@ -10,15 +10,14 @@ -} module Data.Standards.ISO.Country.Primary ( module Data.Standards.ISO.Country.Primary.Translation- , A2.Alpha2 ( .. )- , A3.Alpha3 ( .. )- , N.Numeric ( .. )- , C.Status ( .. )+ , Alpha2 ( .. )+ , Alpha3 ( .. )+ , Numeric ( .. )+ , Status ( .. ) ) where -import qualified Data.Standards.ISO.Country.Primary.Alpha2 as A2-import qualified Data.Standards.ISO.Country.Primary.Alpha3 as A3-import qualified Data.Standards.ISO.Country.Primary.Common as C-import qualified Data.Standards.ISO.Country.Primary.Numeric as N+import Data.Standards.ISO.Country.Primary.Alpha2+import Data.Standards.ISO.Country.Primary.Alpha3+import Data.Standards.ISO.Country.Primary.Numeric import Data.Standards.ISO.Country.Primary.Translation
Data/Standards/ISO/Country/Primary/Alpha2.hs view
@@ -344,7 +344,7 @@ | SV -- ^ El Salvador | SX -- ^ Sint Maarten (Dutch part) | SY -- ^ Syrian Arab Republic- | SZ -- ^ Swaziland+ | SZ -- ^ Eswatini | TA -- ^ 'ExceptionalReservation': Tristan da Cunha | TC -- ^ Turks and Caicos Islands (the)@@ -401,7 +401,7 @@ | ZM -- ^ Zambia | ZR -- ^ 'TransitionalReservation': Zaire | ZW -- ^ Zimbabwe- deriving ( Eq, Show, Read, Enum, Bounded )+ deriving ( Eq, Show, Read, Ord, Enum, Bounded ) instance H.Hashable Alpha2 where hashWithSalt = H.hashUsing fromEnum
Data/Standards/ISO/Country/Primary/Alpha3.hs view
@@ -375,7 +375,7 @@ | SVK -- ^ Slovakia | SVN -- ^ Slovenia | SWE -- ^ Sweden- | SWZ -- ^ Swaziland+ | SWZ -- ^ Eswatini | SXM -- ^ Sint Maarten (Dutch part) | SYC -- ^ Seychelles | SYR -- ^ Syrian Arab Republic@@ -434,7 +434,7 @@ | ZMB -- ^ Zambia | ZRE -- ^ 'IndeterminateReservation': Zaire (road vehicles) | ZWE -- ^ Zimbabwe- deriving ( Eq, Show, Read, Enum, Bounded )+ deriving ( Eq, Show, Read, Ord, Enum, Bounded ) instance H.Hashable Alpha3 where hashWithSalt = H.hashUsing fromEnum
Data/Standards/ISO/Country/Primary/Numeric.hs view
@@ -298,7 +298,7 @@ | C736 -- ^ 'Withdrawn': Sudan (the) | C740 -- ^ Suriname | C744 -- ^ Svalbard and Jan Mayen- | C748 -- ^ Swaziland+ | C748 -- ^ Eswatini | C752 -- ^ Sweden | C756 -- ^ Switzerland@@ -342,7 +342,7 @@ | C890 -- ^ 'Withdrawn': Yugoslavia (Socialist Federal Republic of) | C891 -- ^ 'Withdrawn': Serbia and Montenegro | C894 -- ^ Zambia- deriving ( Eq, Show, Read, Bounded )+ deriving ( Eq, Show, Read, Ord, Bounded ) -- | The 'Int' values returned or processed by this instance are the true value -- of the country code, rather than being incremental.@@ -362,25 +362,28 @@ -- 'Int' lists -- running into the same problem with 6.3.4 -- and having a -- note that explicitly says they only make sense for injective mappings). enumFrom = flip enumFromTo maxBound- enumFromThen x y = enumFromThenTo x y bound- where bound- | fromEnum x <= fromEnum y = maxBound- | otherwise = minBound- enumFromTo x y- | x == y = [x]- | fromEnum x > fromEnum y = []- | otherwise = x : enumFromTo (succ x) y+ | x > y = []+ | x == y = [x]+ | otherwise = x : enumFromTo (succ x) y - enumFromThenTo x1 x2 y- | x1 == y = []- | otherwise = x1 : count x1 x2- where count x1' x2'- | (fromEnum x2' <= fromEnum y) /= forward = [x2]- | x1' == x2 = enumFromThenTo x1' x2' y- | forward = count (succ x1') (succ x2')- | otherwise = count (pred x1') (pred x2')- forward = fromEnum x1 < fromEnum x2+ enumFromThen x s = enumFromThenTo x s bound+ where bound+ | x <= s = maxBound+ | otherwise = minBound+ enumFromThenTo x s y+ | past x y = []+ | otherwise = x : skipOver thenTo+ where (ln, thenTo) = break (== s) $ fromTo x+ fromTo x1+ | x1 == y = [x1]+ | otherwise = x1 : fromTo (step x1)+ (past, step)+ | x <= s = ((>), succ)+ | otherwise = ((<), pred)+ n = length ln+ skipOver [] = []+ skipOver xs@(x1:_) = x1 : skipOver (drop n xs) --TODO: Depending on how the compiler transforms these, it might be better -- to put them into a lookup table; check with benchmarking.@@ -632,7 +635,7 @@ succ C891 = C894 succ c- | c == maxBound = error "tried to take `succ' of last tag in enumeration"+ | c == maxBound = error "succ(Numeric) tried to take `succ' of last tag in enumeration" | otherwise = toEnum . (+) 1 $ fromEnum c pred C008 = C004@@ -883,7 +886,7 @@ pred C894 = C891 pred c- | c == minBound = error "tried to take `pred' of first tag in enumeration"+ | c == minBound = error "pred(Numeric) tried to take `pred' of first tag in enumeration" | otherwise = toEnum . subtract 1 $ fromEnum c instance H.Hashable Numeric where
data-standards.cabal view
@@ -3,13 +3,15 @@ category: Data synopsis: A collection of standards representable by simple data types. +version: 0.1.0.1+stability: provisional+maintainer: ag.eitilt@gmail.com+ copyright: (c) 2018 Samuel May license: MPL-2.0 license-file: LICENSE--version: 0.1.0.0-stability: provisional-maintainer: ag.eitilt@gmail.com+extra-source-files: ChangeLog.md+ , README.md homepage: https://github.com/ag-eitilt/data-standards bug-reports: https://github.com/ag-eitilt/data-standards/issues@@ -18,10 +20,8 @@ the ISO 3166-1 specification. cabal-version: >=1.10-extra-source-files: ChangeLog.md- , README.md build-type: Simple-tested-with: GHC ==8.0.2+tested-with: GHC ==8.0.2, GHC ==8.4.3 source-repository head type: git@@ -30,7 +30,7 @@ source-repository this type: git location: git://github.com/ag-eitilt/data-standards.git- tag: v0.1.0.0+ tag: v0.1.0.1 library exposed-modules: Data.Standards.ISO.Country.Primary@@ -39,7 +39,7 @@ , Data.Standards.ISO.Country.Primary.Numeric , Data.Standards.ISO.Country.Primary.Translation other-modules: Data.Standards.ISO.Country.Primary.Common- build-depends: base >=4.9 && <4.10+ build-depends: base >=4.9 && <4.12 , hashable >=1.2 && <1.3 , unordered-containers <0.3 default-language: Haskell98