packages feed

names-th 0.3.0.0 → 0.3.0.1

raw patch · 2 files changed

+37/−11 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

names-th.cabal view
@@ -1,5 +1,5 @@ name:                names-th-version:             0.3.0.0+version:             0.3.0.1 synopsis:            Manipulate name strings for TH description:         This package includes functions to manipulate name string                      and extra library functions for Template Haskell.@@ -8,11 +8,13 @@ license-file:        LICENSE author:              Kei Hibino maintainer:          ex8k.hibino@gmail.com-copyright:           Copyright (c) 2013-2018 Kei Hibino, 2015 Shohei Murayama+copyright:           Copyright (c) 2013-2020 Kei Hibino, 2015 Shohei Murayama category:            Development build-type:          Simple cabal-version:       >=1.10-tested-with:           GHC == 8.4.1, GHC == 8.4.2, GHC == 8.4.3+tested-with:           GHC == 8.8.1, GHC == 8.8.2+                     , GHC == 8.6.1, GHC == 8.6.2, GHC == 8.6.3, GHC == 8.6.4, GHC == 8.6.5+                     , GHC == 8.4.1, GHC == 8.4.2, GHC == 8.4.3, GHC == 8.4.4                      , GHC == 8.2.1, GHC == 8.2.2                      , GHC == 8.0.1, GHC == 8.0.2                      , GHC == 7.10.1, GHC == 7.10.2, GHC == 7.10.3@@ -22,13 +24,17 @@  library   exposed-modules:-                     Language.Haskell.TH.Name.CamelCase-                     Language.Haskell.TH.Lib.Extra+                       Language.Haskell.TH.Name.CamelCase+                       Language.Haskell.TH.Lib.Extra   build-depends:       base <5, containers, template-haskell-  hs-source-dirs:    src-  ghc-options:       -Wall+  hs-source-dirs:      src+  ghc-options:         -Wall+  if impl(ghc >= 8)+    ghc-options:         -Wcompat+  if impl(ghc >= 8) && impl(ghc < 8.8)+    ghc-options:         -Wnoncanonical-monadfail-instances -  default-language:     Haskell2010+  default-language:    Haskell2010   source-repository head
src/Language/Haskell/TH/Name/CamelCase.hs view
@@ -25,7 +25,7 @@   toVarExp, toVarPat,   ) where -import Data.Char (toUpper, toLower)+import Data.Char (toUpper, toLower, isLetter, isDigit) import Data.Set (Set, fromList, member) import Language.Haskell.TH   (Name, mkName, TypeQ, conT, ExpQ, conE, varE, PatQ, varP)@@ -38,6 +38,24 @@ unCapitalize (c:cs) = toLower c : cs unCapitalize ""     = "" +-- Adds a _ to the identifier which does not start with a letter or an+-- underscore.+letterStart :: String -> String+letterStart (c:cs) | c == '_'   ||+                     isLetter c    = c:cs+                   | otherwise     = '_':c:cs+letterStart ""                     = ""++-- Only letters, digits, underscores and single quotes are allowed in an+-- identifier.+allowedChars :: String -> String+allowedChars cs = map replaceUnallowed cs+  where+    replaceUnallowed c | isLetter c    ||+                         isDigit  c    ||+                         c `elem` "_'"    = c+                       | otherwise        = '_'+ -- | rename the string that equals to reserved identifiers. rename :: String -> String rename cs | cs `member` reservedIds = cs ++ "_"@@ -62,14 +80,16 @@  -- | Make constructor name from 'String'. toConName :: String -> ConName-toConName =  ConName . mkName . rename . capitalize+toConName =  ConName . mkName . rename . capitalize .+             allowedChars . letterStart  -- | Type to wrap variable\'s 'Name'. newtype VarName = VarName { varName :: Name {- ^ Get wrapped 'Name' -} }  -- | Make variable name from 'String'. toVarName :: String -> VarName-toVarName =  VarName . mkName . rename . unCapitalize+toVarName =  VarName . mkName . rename . unCapitalize .+             allowedChars . letterStart  -- | 'Char' set used from camel-cased names. nameChars :: String