git.iko.soy/typeable/country-codes
on 2cfae88 help sign in
4 files changed+14−97
since splitsnapshots
unifiedsplit
.gitignore−2 country-codes.cabal+3−12 src/Data/CountryCodes/ISO31661.hs+11−71 stack.yaml−12
.gitignore−2
@@ -11,5 +11,3 @@ cabal.sandbox.config
1111cabal.config
1212.dist-buildwrapper
1313.project
14−.stack-work
15−*.history
country-codes.cabal+3−12
@@ -1,5 +1,5 @@
11name: country-codes
2−version: 0.1.4
2+version: 0.1.3
33cabal-version: >= 1.8
44build-type: Simple
55author: JP Moresmau <jpmoresmau@gmail.com>
@@ -30,15 +30,7 @@ library
3030 base >= 4 && < 5
3131 , text >= 0.11
3232 , aeson >= 0.5
33− , deepseq >= 1.4
34− , shakespeare
35− -- == 2.0.*
36− if !(impl(ghcjs) || arch(javascript) || arch(wasm32))
37− build-depends:
38− openapi3
39− , QuickCheck
40− , generic-arbitrary
41− cpp-options: -DBACKEND
33+ , shakespeare == 2.0.*
4234 ghc-options: -Wall
4335 other-modules: Data.CountryCodes.ISO31661
4436 exposed-modules: Data.CountryCodes
@@ -49,8 +41,7 @@ executable country-codes-generate
4941 build-depends:
5042 base >= 4 && < 5
5143 , text >= 0.11
52− , tagsoup >= 0.13
53− -- && < 0.15
44+ , tagsoup >= 0.13 && < 0.15
5445 ghc-options: -Wall -rtsopts
5546 main-is: Main.hs
5647 if !flag(generate)
src/Data/CountryCodes/ISO31661.hs+11−71
@@ -1,7 +1,4 @@
1−{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, NoImplicitPrelude
2− , DeriveGeneric, DeriveAnyClass, PatternGuards, FlexibleInstances
3− , MultiParamTypeClasses, StandaloneDeriving, CPP #-}
4−{-# OPTIONS_GHC -fconstraint-solver-iterations=10 #-}
1+{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, NoImplicitPrelude, PatternGuards, FlexibleInstances, MultiParamTypeClasses #-}
52-- | This file is generated from the Wikipedia page
63-- <http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>
74module Data.CountryCodes.ISO31661 (
@@ -16,20 +13,13 @@ module Data.CountryCodes.ISO31661 (
1613) where
1714
1815import Control.Applicative (pure)
19−import Control.DeepSeq (NFData(..))
20−import Data.Aeson
21−import Data.Typeable
22−import Data.Text as T
23−import GHC.Generics
24−import Prelude (Show,Read,Eq,Ord,Bounded,Enum,error,($),(++),Maybe(..),(.),fail,seq)
25−import Text.Shakespeare.I18N
26−#ifdef BACKEND
27−import Data.OpenApi
28−import Test.QuickCheck.Arbitrary
29−import Test.QuickCheck.Arbitrary.Generic
30−#endif
16+import Data.Aeson
17+import Data.Typeable
18+import qualified Data.Text as T
19+import Prelude (Show,Read,Eq,Ord,Bounded,Enum,error,($),(++),Maybe(..),(.),fail)
20+import Text.Shakespeare.I18N
3121
32−data CountryCode =
22+data CountryCode =
3323 AD
3424 | AE
3525 | AF
@@ -279,19 +269,7 @@ data CountryCode =
279269 | ZA
280270 | ZM
281271 | ZW
282− -- Added these non standard codes that occur in
283− -- travolutionary database
284− -- https://typeable.atlassian.net/browse/B2H-796
285− | XA
286− | AN
287− | XK
288− | XC
289− | WE
290− deriving (Show,Read,Eq,Ord,Bounded,Enum,Typeable, Generic
291−#ifdef BACKEND
292− , ToSchema
293−#endif
294− )
272+ deriving (Show,Read,Eq,Ord,Bounded,Enum,Typeable)
295273
296274-- | Maybe get the CountryCode from the text code.
297275fromMText :: T.Text -> Maybe CountryCode
@@ -544,11 +522,6 @@ fromMText "YT" = Just YT
544522fromMText "ZA" = Just ZA
545523fromMText "ZM" = Just ZM
546524fromMText "ZW" = Just ZW
547−fromMText "XA" = Just XA
548−fromMText "AN" = Just AN
549−fromMText "XK" = Just XK
550−fromMText "XC" = Just XC
551−fromMText "WE" = Just WE
552525fromMText _ = Nothing
553526
554527-- | Get the CountryCode from the text code. Errors if the code is unknown
@@ -808,11 +781,6 @@ toText YT = "YT"
808781toText ZA = "ZA"
809782toText ZM = "ZM"
810783toText ZW = "ZW"
811−toText XA = "XA"
812−toText AN = "AN"
813−toText XK = "XK"
814−toText XC = "XC"
815−toText WE = "WE"
816784
817785-- | Maybe get the code from the user readable name.
818786fromMName :: T.Text -> Maybe CountryCode
@@ -1065,11 +1033,6 @@ fromMName "Mayotte" = Just YT
10651033fromMName "South Africa" = Just ZA
10661034fromMName "Zambia" = Just ZM
10671035fromMName "Zimbabwe" = Just ZW
1068−fromMName "Canary Islands" = Just XA
1069−fromMName "Netherlands Antilles" = Just AN
1070−fromMName "Kosovo" = Just XK
1071−fromMName "Ceuta" = Just XC
1072−fromMName "West Bank" = Just WE
10731036fromMName _ = Nothing
10741037
10751038-- | Get the CountryCode from the user readable name. Errors if the name is unknown
@@ -1329,11 +1292,6 @@ toName YT = "Mayotte"
13291292toName ZA = "South Africa"
13301293toName ZM = "Zambia"
13311294toName ZW = "Zimbabwe"
1332−toName XA = "Canary Islands"
1333−toName AN = "Netherlands Antilles"
1334−toName XK = "Kosovo"
1335−toName XC = "Ceuta"
1336−toName WE = "West Bank"
13371295
13381296-- | list of names sorted by alphabetical order, with country code
13391297-- this is ready to be used in a yesod selectField, for example
@@ -1586,37 +1544,19 @@ countryList = [("Afghanistan",AF)
15861544 ,("Yemen",YE)
15871545 ,("Zambia",ZM)
15881546 ,("Zimbabwe",ZW)
1589− ,("Åland Islands",AX)
1590− ,("Canary Islands", XA)
1591− ,("Netherlands Antilles",AN)
1592− ,("Kosovo",XK)
1593− ,("Ceuta",XC)
1594− ,("West Bank",WE)
1595− ]
1547+ ,("Åland Islands",AX) ]
15961548
15971549-- | to json: as a simple string
15981550instance ToJSON CountryCode where
1599− toJSON = toJSON . toText
1551+ toJSON =toJSON . toText
16001552
16011553-- | from json: as a simple string
16021554instance FromJSON CountryCode where
16031555 parseJSON (String s)
16041556 | Just a <- fromMText s=pure a
1605− parseJSON _ = fail "CountryCode"
1606−
1607−deriving instance ToJSONKey CountryCode
1608−deriving instance FromJSONKey CountryCode
1557+ parseJSON _ =fail "CountryCode"
16091558
16101559-- | show user readable name, in English (ignoring locale for now)
16111560instance RenderMessage master CountryCode where
16121561 renderMessage _ _ = toName
16131562
1614−-- | Allow the deep evaluation of CountryCode with `deepseq`
1615−instance NFData CountryCode where
1616− rnf a = a `seq` ()
1617−
1618−#ifdef BACKEND
1619−instance Arbitrary CountryCode where
1620− arbitrary = genericArbitrary
1621− shrink = genericShrink
1622−#endif
stack.yamldeleted−12
@@ -1,12 +0,0 @@
1−resolver: lts-21.3
2−
3−packages:
4−- .
5−
6−# extra-deps:
7−# - git: https://github.com/typeable/openapi3.git
8−# # nix-sha256: 1aqn5dia4aqwpmr3v0rcb8kzhknp5674hhay8h7p76206dx83ykg
9−# commit: bb1c64f8501535143c92907166fdc9f8df6d51b9
10−# - git: https://github.com/typeable/generic-arbitrary.git
11−# # nix-sha256: 01k87zxa8cd5ssy1wiqwyqqvz4v7lvh3q6cipmadg4w2ynmfbdn0
12−# commit: 84c62a4de517c78e5080f5451714ce7944987ba6