iso639 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+270/−250 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- Data/LanguageCodes.hs +190/−187
- generator/Generate.hs +65/−49
- iso639.cabal +15/−14
Data/LanguageCodes.hs view
@@ -1,4 +1,7 @@-module Data.LanguageCodes where+module Data.LanguageCodes+ {-# WARNING "\nThis module code was generated by the functions in\ngenerator/Generate.hs (included in the tar.gz).\nPlease don't change this code."+ #-}+ where import Prelude hiding (Ordering(..)) data ISO639_1 = AA@@ -374,190 +377,191 @@ (ZU) -> ('z', 'u') fromChars (c1) (c2) = case ((c1), (c2)) of- ('a', 'a') -> (AA)- ('a', 'b') -> (AB)- ('a', 'e') -> (AE)- ('a', 'f') -> (AF)- ('a', 'k') -> (AK)- ('a', 'm') -> (AM)- ('a', 'n') -> (AN)- ('a', 'r') -> (AR)- ('a', 's') -> (AS)- ('a', 'v') -> (AV)- ('a', 'y') -> (AY)- ('a', 'z') -> (AZ)- ('b', 'a') -> (BA)- ('b', 'e') -> (BE)- ('b', 'g') -> (BG)- ('b', 'h') -> (BH)- ('b', 'i') -> (BI)- ('b', 'm') -> (BM)- ('b', 'n') -> (BN)- ('b', 'o') -> (BO)- ('b', 'r') -> (BR)- ('b', 's') -> (BS)- ('c', 'a') -> (CA)- ('c', 'e') -> (CE)- ('c', 'h') -> (CH)- ('c', 'o') -> (CO)- ('c', 'r') -> (CR)- ('c', 's') -> (CS)- ('c', 'u') -> (CU)- ('c', 'v') -> (CV)- ('c', 'y') -> (CY)- ('d', 'a') -> (DA)- ('d', 'e') -> (DE)- ('d', 'v') -> (DV)- ('d', 'z') -> (DZ)- ('e', 'e') -> (EE)- ('e', 'l') -> (EL)- ('e', 'n') -> (EN)- ('e', 'o') -> (EO)- ('e', 's') -> (ES)- ('e', 't') -> (ET)- ('e', 'u') -> (EU)- ('f', 'a') -> (FA)- ('f', 'f') -> (FF)- ('f', 'i') -> (FI)- ('f', 'j') -> (FJ)- ('f', 'o') -> (FO)- ('f', 'r') -> (FR)- ('f', 'y') -> (FY)- ('g', 'a') -> (GA)- ('g', 'd') -> (GD)- ('g', 'l') -> (GL)- ('g', 'n') -> (GN)- ('g', 'u') -> (GU)- ('g', 'v') -> (GV)- ('h', 'a') -> (HA)- ('h', 'e') -> (HE)- ('h', 'i') -> (HI)- ('h', 'o') -> (HO)- ('h', 'r') -> (HR)- ('h', 't') -> (HT)- ('h', 'u') -> (HU)- ('h', 'y') -> (HY)- ('h', 'z') -> (HZ)- ('i', 'a') -> (IA)- ('i', 'd') -> (ID)- ('i', 'e') -> (IE)- ('i', 'g') -> (IG)- ('i', 'i') -> (II)- ('i', 'k') -> (IK)- ('i', 'o') -> (IO)- ('i', 's') -> (IS)- ('i', 't') -> (IT)- ('i', 'u') -> (IU)- ('j', 'a') -> (JA)- ('j', 'v') -> (JV)- ('k', 'a') -> (KA)- ('k', 'g') -> (KG)- ('k', 'i') -> (KI)- ('k', 'j') -> (KJ)- ('k', 'k') -> (KK)- ('k', 'l') -> (KL)- ('k', 'm') -> (KM)- ('k', 'n') -> (KN)- ('k', 'o') -> (KO)- ('k', 'r') -> (KR)- ('k', 's') -> (KS)- ('k', 'u') -> (KU)- ('k', 'v') -> (KV)- ('k', 'w') -> (KW)- ('k', 'y') -> (KY)- ('l', 'a') -> (LA)- ('l', 'b') -> (LB)- ('l', 'g') -> (LG)- ('l', 'i') -> (LI)- ('l', 'n') -> (LN)- ('l', 'o') -> (LO)- ('l', 't') -> (LT)- ('l', 'u') -> (LU)- ('l', 'v') -> (LV)- ('m', 'g') -> (MG)- ('m', 'h') -> (MH)- ('m', 'i') -> (MI)- ('m', 'k') -> (MK)- ('m', 'l') -> (ML)- ('m', 'n') -> (MN)- ('m', 'r') -> (MR)- ('m', 's') -> (MS)- ('m', 't') -> (MT)- ('m', 'y') -> (MY)- ('n', 'a') -> (NA)- ('n', 'b') -> (NB)- ('n', 'd') -> (ND)- ('n', 'e') -> (NE)- ('n', 'g') -> (NG)- ('n', 'l') -> (NL)- ('n', 'n') -> (NN)- ('n', 'o') -> (NO)- ('n', 'r') -> (NR)- ('n', 'v') -> (NV)- ('n', 'y') -> (NY)- ('o', 'c') -> (OC)- ('o', 'j') -> (OJ)- ('o', 'm') -> (OM)- ('o', 'r') -> (OR)- ('o', 's') -> (OS)- ('p', 'a') -> (PA)- ('p', 'i') -> (PI)- ('p', 'l') -> (PL)- ('p', 's') -> (PS)- ('p', 't') -> (PT)- ('q', 'u') -> (QU)- ('r', 'm') -> (RM)- ('r', 'n') -> (RN)- ('r', 'o') -> (RO)- ('r', 'u') -> (RU)- ('r', 'w') -> (RW)- ('s', 'a') -> (SA)- ('s', 'c') -> (SC)- ('s', 'd') -> (SD)- ('s', 'e') -> (SE)- ('s', 'g') -> (SG)- ('s', 'i') -> (SI)- ('s', 'k') -> (SK)- ('s', 'l') -> (SL)- ('s', 'm') -> (SM)- ('s', 'n') -> (SN)- ('s', 'o') -> (SO)- ('s', 'q') -> (SQ)- ('s', 'r') -> (SR)- ('s', 's') -> (SS)- ('s', 't') -> (ST)- ('s', 'u') -> (SU)- ('s', 'v') -> (SV)- ('s', 'w') -> (SW)- ('t', 'a') -> (TA)- ('t', 'e') -> (TE)- ('t', 'g') -> (TG)- ('t', 'h') -> (TH)- ('t', 'i') -> (TI)- ('t', 'k') -> (TK)- ('t', 'l') -> (TL)- ('t', 'n') -> (TN)- ('t', 'o') -> (TO)- ('t', 'r') -> (TR)- ('t', 's') -> (TS)- ('t', 't') -> (TT)- ('t', 'w') -> (TW)- ('t', 'y') -> (TY)- ('u', 'g') -> (UG)- ('u', 'k') -> (UK)- ('u', 'r') -> (UR)- ('u', 'z') -> (UZ)- ('v', 'e') -> (VE)- ('v', 'i') -> (VI)- ('v', 'o') -> (VO)- ('w', 'a') -> (WA)- ('w', 'o') -> (WO)- ('x', 'h') -> (XH)- ('y', 'i') -> (YI)- ('y', 'o') -> (YO)- ('z', 'a') -> (ZA)- ('z', 'h') -> (ZH)- ('z', 'u') -> (ZU)+ ('z', 'u') -> (Just) (ZU)+ ('z', 'h') -> (Just) (ZH)+ ('z', 'a') -> (Just) (ZA)+ ('y', 'o') -> (Just) (YO)+ ('y', 'i') -> (Just) (YI)+ ('x', 'h') -> (Just) (XH)+ ('w', 'o') -> (Just) (WO)+ ('w', 'a') -> (Just) (WA)+ ('v', 'o') -> (Just) (VO)+ ('v', 'i') -> (Just) (VI)+ ('v', 'e') -> (Just) (VE)+ ('u', 'z') -> (Just) (UZ)+ ('u', 'r') -> (Just) (UR)+ ('u', 'k') -> (Just) (UK)+ ('u', 'g') -> (Just) (UG)+ ('t', 'y') -> (Just) (TY)+ ('t', 'w') -> (Just) (TW)+ ('t', 't') -> (Just) (TT)+ ('t', 's') -> (Just) (TS)+ ('t', 'r') -> (Just) (TR)+ ('t', 'o') -> (Just) (TO)+ ('t', 'n') -> (Just) (TN)+ ('t', 'l') -> (Just) (TL)+ ('t', 'k') -> (Just) (TK)+ ('t', 'i') -> (Just) (TI)+ ('t', 'h') -> (Just) (TH)+ ('t', 'g') -> (Just) (TG)+ ('t', 'e') -> (Just) (TE)+ ('t', 'a') -> (Just) (TA)+ ('s', 'w') -> (Just) (SW)+ ('s', 'v') -> (Just) (SV)+ ('s', 'u') -> (Just) (SU)+ ('s', 't') -> (Just) (ST)+ ('s', 's') -> (Just) (SS)+ ('s', 'r') -> (Just) (SR)+ ('s', 'q') -> (Just) (SQ)+ ('s', 'o') -> (Just) (SO)+ ('s', 'n') -> (Just) (SN)+ ('s', 'm') -> (Just) (SM)+ ('s', 'l') -> (Just) (SL)+ ('s', 'k') -> (Just) (SK)+ ('s', 'i') -> (Just) (SI)+ ('s', 'g') -> (Just) (SG)+ ('s', 'e') -> (Just) (SE)+ ('s', 'd') -> (Just) (SD)+ ('s', 'c') -> (Just) (SC)+ ('s', 'a') -> (Just) (SA)+ ('r', 'w') -> (Just) (RW)+ ('r', 'u') -> (Just) (RU)+ ('r', 'o') -> (Just) (RO)+ ('r', 'n') -> (Just) (RN)+ ('r', 'm') -> (Just) (RM)+ ('q', 'u') -> (Just) (QU)+ ('p', 't') -> (Just) (PT)+ ('p', 's') -> (Just) (PS)+ ('p', 'l') -> (Just) (PL)+ ('p', 'i') -> (Just) (PI)+ ('p', 'a') -> (Just) (PA)+ ('o', 's') -> (Just) (OS)+ ('o', 'r') -> (Just) (OR)+ ('o', 'm') -> (Just) (OM)+ ('o', 'j') -> (Just) (OJ)+ ('o', 'c') -> (Just) (OC)+ ('n', 'y') -> (Just) (NY)+ ('n', 'v') -> (Just) (NV)+ ('n', 'r') -> (Just) (NR)+ ('n', 'o') -> (Just) (NO)+ ('n', 'n') -> (Just) (NN)+ ('n', 'l') -> (Just) (NL)+ ('n', 'g') -> (Just) (NG)+ ('n', 'e') -> (Just) (NE)+ ('n', 'd') -> (Just) (ND)+ ('n', 'b') -> (Just) (NB)+ ('n', 'a') -> (Just) (NA)+ ('m', 'y') -> (Just) (MY)+ ('m', 't') -> (Just) (MT)+ ('m', 's') -> (Just) (MS)+ ('m', 'r') -> (Just) (MR)+ ('m', 'n') -> (Just) (MN)+ ('m', 'l') -> (Just) (ML)+ ('m', 'k') -> (Just) (MK)+ ('m', 'i') -> (Just) (MI)+ ('m', 'h') -> (Just) (MH)+ ('m', 'g') -> (Just) (MG)+ ('l', 'v') -> (Just) (LV)+ ('l', 'u') -> (Just) (LU)+ ('l', 't') -> (Just) (LT)+ ('l', 'o') -> (Just) (LO)+ ('l', 'n') -> (Just) (LN)+ ('l', 'i') -> (Just) (LI)+ ('l', 'g') -> (Just) (LG)+ ('l', 'b') -> (Just) (LB)+ ('l', 'a') -> (Just) (LA)+ ('k', 'y') -> (Just) (KY)+ ('k', 'w') -> (Just) (KW)+ ('k', 'v') -> (Just) (KV)+ ('k', 'u') -> (Just) (KU)+ ('k', 's') -> (Just) (KS)+ ('k', 'r') -> (Just) (KR)+ ('k', 'o') -> (Just) (KO)+ ('k', 'n') -> (Just) (KN)+ ('k', 'm') -> (Just) (KM)+ ('k', 'l') -> (Just) (KL)+ ('k', 'k') -> (Just) (KK)+ ('k', 'j') -> (Just) (KJ)+ ('k', 'i') -> (Just) (KI)+ ('k', 'g') -> (Just) (KG)+ ('k', 'a') -> (Just) (KA)+ ('j', 'v') -> (Just) (JV)+ ('j', 'a') -> (Just) (JA)+ ('i', 'u') -> (Just) (IU)+ ('i', 't') -> (Just) (IT)+ ('i', 's') -> (Just) (IS)+ ('i', 'o') -> (Just) (IO)+ ('i', 'k') -> (Just) (IK)+ ('i', 'i') -> (Just) (II)+ ('i', 'g') -> (Just) (IG)+ ('i', 'e') -> (Just) (IE)+ ('i', 'd') -> (Just) (ID)+ ('i', 'a') -> (Just) (IA)+ ('h', 'z') -> (Just) (HZ)+ ('h', 'y') -> (Just) (HY)+ ('h', 'u') -> (Just) (HU)+ ('h', 't') -> (Just) (HT)+ ('h', 'r') -> (Just) (HR)+ ('h', 'o') -> (Just) (HO)+ ('h', 'i') -> (Just) (HI)+ ('h', 'e') -> (Just) (HE)+ ('h', 'a') -> (Just) (HA)+ ('g', 'v') -> (Just) (GV)+ ('g', 'u') -> (Just) (GU)+ ('g', 'n') -> (Just) (GN)+ ('g', 'l') -> (Just) (GL)+ ('g', 'd') -> (Just) (GD)+ ('g', 'a') -> (Just) (GA)+ ('f', 'y') -> (Just) (FY)+ ('f', 'r') -> (Just) (FR)+ ('f', 'o') -> (Just) (FO)+ ('f', 'j') -> (Just) (FJ)+ ('f', 'i') -> (Just) (FI)+ ('f', 'f') -> (Just) (FF)+ ('f', 'a') -> (Just) (FA)+ ('e', 'u') -> (Just) (EU)+ ('e', 't') -> (Just) (ET)+ ('e', 's') -> (Just) (ES)+ ('e', 'o') -> (Just) (EO)+ ('e', 'n') -> (Just) (EN)+ ('e', 'l') -> (Just) (EL)+ ('e', 'e') -> (Just) (EE)+ ('d', 'z') -> (Just) (DZ)+ ('d', 'v') -> (Just) (DV)+ ('d', 'e') -> (Just) (DE)+ ('d', 'a') -> (Just) (DA)+ ('c', 'y') -> (Just) (CY)+ ('c', 'v') -> (Just) (CV)+ ('c', 'u') -> (Just) (CU)+ ('c', 's') -> (Just) (CS)+ ('c', 'r') -> (Just) (CR)+ ('c', 'o') -> (Just) (CO)+ ('c', 'h') -> (Just) (CH)+ ('c', 'e') -> (Just) (CE)+ ('c', 'a') -> (Just) (CA)+ ('b', 's') -> (Just) (BS)+ ('b', 'r') -> (Just) (BR)+ ('b', 'o') -> (Just) (BO)+ ('b', 'n') -> (Just) (BN)+ ('b', 'm') -> (Just) (BM)+ ('b', 'i') -> (Just) (BI)+ ('b', 'h') -> (Just) (BH)+ ('b', 'g') -> (Just) (BG)+ ('b', 'e') -> (Just) (BE)+ ('b', 'a') -> (Just) (BA)+ ('a', 'z') -> (Just) (AZ)+ ('a', 'y') -> (Just) (AY)+ ('a', 'v') -> (Just) (AV)+ ('a', 's') -> (Just) (AS)+ ('a', 'r') -> (Just) (AR)+ ('a', 'n') -> (Just) (AN)+ ('a', 'm') -> (Just) (AM)+ ('a', 'k') -> (Just) (AK)+ ('a', 'f') -> (Just) (AF)+ ('a', 'e') -> (Just) (AE)+ ('a', 'b') -> (Just) (AB)+ ('a', 'a') -> (Just) (AA)+ _ -> (Nothing) language (code) = case (code) of (AA) -> "Afar"@@ -624,8 +628,7 @@ (HU) -> "Hungarian" (HY) -> "Armenian" (HZ) -> "Herero"- (IA)- -> "Interlingua (International Auxiliary Language Association)"+ (IA) -> "Interlingua (International Auxiliary Language Association)" (ID) -> "Indonesian" (IE) -> "Interlingue" (IG) -> "Igbo"
generator/Generate.hs view
@@ -1,8 +1,8 @@ module Generate where --- needs: haskell-src, curl >= 1.3.8-import Language.Haskell.Syntax-import Language.Haskell.Pretty+-- needs: haskell-src-exts, curl >= 1.3.8+import Language.Haskell.Exts.Syntax+import Language.Haskell.Exts.Pretty import Data.Char (toUpper) import Network.HTTP@@ -12,67 +12,83 @@ import Data.List gen triples = prettyPrint $ - -- HsModule SrcLoc Module (Maybe [HsExportSpec]) [HsImportDecl] [HsDecl]- HsModule (SrcLoc n 0 0) (Module n) Nothing - [HsImportDecl loc (Module "Prelude") False Nothing - (Just (True, [HsIThingAll (HsSymbol "Ordering") ]))+ -- Module SrcLoc ModuleName [ModulePragma] (Maybe WarningText) (Maybe [ExportSpec]) [ImportDecl] [Decl] + Module (SrcLoc n 0 0) (ModuleName n) [] (Just $ WarnText warn) Nothing + [ImportDecl loc (ModuleName "Prelude") False False False Nothing Nothing+ (Just (True, [IThingAll (Ident "Ordering") ])) -- hidding Ordering because of the symbol LT ] - [iso639_1, iso639_1_show, iso639_1_read, iso639_1_name]+ [iso639_1, toCharsFun, fromCharsFun, languageFun] where n = "Data.LanguageCodes" loc = SrcLoc n 0 0 - iso639_1 = HsDataDecl loc [] (HsIdent "ISO639_1") [] - (codes languages_1) (map (UnQual . HsIdent) ["Show", "Read", "Eq", "Enum", "Ord"])- code (_,c) = HsConDecl loc (HsIdent (map toUpper c)) []+ warn = "\nThis module code was generated by the functions in\n" ++ + "generator/Generate.hs (included in the tar.gz).\nPlease " +++ "don't change this code."+ iso639_1 = DataDecl loc DataType [] (Ident "ISO639_1") [] + (codes languages_1) -- constructors+ derivingClasses -- deriving+ code (_,c) = QualConDecl loc [] [] + $ ConDecl (Ident $ map toUpper c) [] codes lst = map code lst languages_1 = catMaybes $ map (\(l,_,c) -> fmap (\a -> (unpack l, unpack a)) c) triples- iso639_1_read = HsFunBind - [ HsMatch loc (HsIdent "fromChars") - [HsPVar (HsSymbol "c1"), HsPVar (HsSymbol "c2")] - ( HsUnGuardedRhs - (HsCase ( HsTuple [ HsVar $ UnQual $ HsSymbol "c1"- , HsVar $ UnQual $ HsSymbol "c2"- ]- ) ( map languageCodeAlt languages_1)- )+ derivingClasses = map (\a -> (UnQual $ Ident a, []) ) + ["Show", "Read", "Eq", "Enum", "Ord"]+ fromCharsFun = FunBind + [ Match loc (Ident "fromChars") + [PVar (Symbol "c1"), PVar (Symbol "c2")] + Nothing+ ( UnGuardedRhs + (Case ( Tuple Boxed [ Var $ UnQual $ Symbol "c1"+ , Var $ UnQual $ Symbol "c2"+ ]+ ) (reverse $ languageNoneAlt + : (map languageCodeAlt languages_1)+ )+ ) )- []+ (BDecls []) ] languageCodeAlt (_,c) = - HsAlt loc (HsPTuple [ HsPLit $ HsChar $ c !! 0- , HsPLit $ HsChar $ c !! 1- ]) - (HsUnGuardedAlt $ HsCon $ UnQual $ HsSymbol $ map toUpper c)- []- iso639_1_show = HsFunBind - [ HsMatch loc (HsIdent "toChars") - [HsPVar (HsSymbol "code")] - ( HsUnGuardedRhs (HsCase ( HsVar $ UnQual $ HsSymbol "code" )- ( map languageAlt languages_1)- )+ Alt loc (PTuple Boxed [ PLit Signless $ Char $ c !! 0+ , PLit Signless $ Char $ c !! 1+ ]) + (UnGuardedRhs $ App (Con $ UnQual $ Symbol "Just")+ (Con $ UnQual $ Symbol $ map toUpper c))+ (BDecls [])+ languageNoneAlt = + Alt loc PWildCard (UnGuardedRhs (Con $ UnQual $ Symbol "Nothing"))+ (BDecls [])+ toCharsFun = FunBind + [ Match loc (Ident "toChars") + [PVar (Symbol "code")] + Nothing+ ( UnGuardedRhs (Case ( Var $ UnQual $ Symbol "code" )+ ( map languageAlt languages_1)+ ) )- []+ (BDecls []) ] languageAlt (_,c) = - HsAlt loc (HsPApp (UnQual $ HsSymbol $ map toUpper c) [])- (HsUnGuardedAlt $ - HsTuple [ HsLit (HsChar $ c !! 0)- , HsLit (HsChar $ c !! 1)- ]) - []- iso639_1_name = HsFunBind - [ HsMatch loc (HsIdent "language") - [HsPVar (HsSymbol "code")] - ( HsUnGuardedRhs (HsCase ( HsVar $ UnQual $ HsSymbol "code" )- ( map languageNameAlt languages_1 )- )+ Alt loc (PApp (UnQual $ Symbol $ map toUpper c) [])+ (UnGuardedRhs $ Tuple Boxed [ Lit (Char $ c !! 0)+ , Lit (Char $ c !! 1)+ ]+ ) + (BDecls [])+ languageFun = FunBind + [ Match loc (Ident "language") + [PVar (Symbol "code")] + Nothing+ ( UnGuardedRhs (Case ( Var $ UnQual $ Symbol "code" )+ ( map languageNameAlt languages_1 )+ ) )- []+ (BDecls []) ] languageNameAlt (n,c) = - HsAlt loc (HsPApp (UnQual $ HsSymbol $ map toUpper c) [])- (HsUnGuardedAlt $ HsLit $ HsString n) - []+ Alt loc (PApp (UnQual $ Symbol $ map toUpper c) [])+ (UnGuardedRhs $ Lit $ String n) + (BDecls []) -- fetch table from official site fetchTable = do
iso639.cabal view
@@ -1,25 +1,26 @@--- Initial iso639.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/- name: iso639-version: 0.1.0.1-synopsis: ISO-639-1 language codes mapping to Haskell datatypes from the official site (http://www.loc.gov/standards/iso639-2/php/English_list.php)--- description: +version: 0.1.0.2+synopsis: ISO-639-1 language codes +homepage: https://github.com/HugoDaniel/iso639+bug-reports: https://github.com/HugoDaniel/iso639/issues+description:+ .+ ISO-639-1 language codes mapping to Haskell datatypes + .+ The code is generated from the <http://www.loc.gov/standards/iso639-2/php/English_list.php official site> using haskell-src-exts in an extra file included in the .tar.gz.+ .+ Special thanks to Petter Bergman for the suggestions and bug fixing+ . license: BSD3 license-file: LICENSE author: HugoDaniel maintainer: mr.hugo.gomes@gmail.com--- copyright: +copyright: 2013-2014 Hugo Daniel Gomes category: Data build-type: Simple extra-source-files: generator/Generate.hs-cabal-version: >=1.10-+cabal-version: >=1.8 library exposed-modules: Data.LanguageCodes- -- other-modules: - -- other-extensions: - build-depends: base >=4.6 && <4.7- -- hs-source-dirs: - default-language: Haskell98+ build-depends: base >=4.6 && <5