git.iko.soy/typeable/country-codes
on master help sign in
countryList, ready to be used in a yesod field
commit3849dc6029cf8d51b524b3d094c54b755f73692d authorjpmoresmau <jp@moresmau.fr> dateSat 26 Apr 2014, 17:39 (12 years ago) parent670b1ae
1 file changed+8−1
src/Data/CountryCodes.hs+8−1
src/Data/CountryCodes.hs+8−1
@@ -1,6 +1,7 @@
11module Data.CountryCodes (
22 CountryCode(..)
33 , allNames
4+ , countryList
45 , fromMText
56 , fromText
67 , fromMName
@@ -13,7 +14,13 @@ import Control.Arrow ((&&&))
1314import Data.Text (Text)
1415
1516import Data.CountryCodes.ISO31661
17+import Data.List (sortBy)
18+import Data.Function (on)
1619
1720-- | list all codes with names
1821allNames :: [(CountryCode,Text)]
19−allNames = map (id &&& toName) $ enumFrom minBound
22+allNames = map (id &&& toName) $ enumFrom minBound
23+
24+-- | list of names sorted by alphabetical order, with country code
25+countryList :: [(Text,CountryCode)]
26+countryList = sortBy (compare `on` fst) $ map (toName &&& id) $ enumFrom minBound