character-cases 0.1.0.5 → 0.1.0.6
raw patch · 3 files changed
+26/−29 lines, 3 filesdep −here
Dependencies removed: here
Files
- character-cases.cabal +2/−4
- src/Data/Char/Cases.hs +22/−23
- src/Data/String/Cases.hs +2/−2
character-cases.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 9ae64163844840cb8871abca02785f7de8a0e19cf7b1793390a33b068ae1a73e+-- hash: 05975857105ecf13977f06dd3fc331dbd0c2c63a6c69bb63e94683d1949baa4c name: character-cases-version: 0.1.0.5+version: 0.1.0.6 synopsis: Exposes subspecies types of Char. And naming cases. description: e.g. meaning of [a-z], [A-Z], [0-9], PascalCase, camelCase, and snake_case. Please see https://github.com/aiya000/hs-character-cases#README.md category: Simple@@ -38,7 +38,6 @@ build-depends: base >=4.7 && <5 , containers- , here , megaparsec , prettyprinter , template-haskell@@ -62,7 +61,6 @@ , base >=4.7 && <5 , containers , doctest- , here , megaparsec , prettyprinter , template-haskell
src/Data/Char/Cases.hs view
@@ -56,7 +56,6 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe (fromJust)-import Data.String.Here (i) import Data.Tuple (swap) import Language.Haskell.TH import Language.Haskell.TH.Quote (QuasiQuoter(..))@@ -111,13 +110,13 @@ expQ [] = fail "alphaNumCharQ required a Char, but nothign is specified." expQ (x : []) = case charToAlphaNum x of- Nothing -> fail [i|'${x}' is not an AlphaNumChar.|]+ Nothing -> fail $ show x <> " is not an AlphaNumChar." Just (AlphaNumAlpha _) -> (ConE (mkName "AlphaNumAlpha") `AppE`) <$> (quoteExp alphaCharQ) [x] Just (AlphaNumDigit _) -> (ConE (mkName "AlphaNumDigit") `AppE`) <$> (quoteExp digitCharQ) [x] - expQ xs@(_ : _) = fail [i|alphaNumCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "alphaNumCharQ required a Char, but a String is specified: " <> xs -- | '[A-Za-z]'@@ -150,13 +149,13 @@ expQ [] = fail "alphaCharQ required a Char, but nothign is specified." expQ (x : []) = case charToAlpha x of- Nothing -> fail [i|'${x}' is not an AlphaChar.|]+ Nothing -> fail $ show x <> " is not an AlphaChar." Just (AlphaLower _) -> (ConE (mkName "AlphaLower") `AppE`) <$> (quoteExp lowerCharQ) [x] Just (AlphaUpper _) -> (ConE (mkName "AlphaUpper") `AppE`) <$> (quoteExp upperCharQ) [x] - expQ xs@(_ : _) = fail [i|alphaCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "alphaCharQ required a Char, but a String is specified: " <> xs -- | '[A-Z]'@@ -211,10 +210,10 @@ expQ [] = fail "upperCharQ required a Char, but nothign is specified." expQ (x : []) = case charToUpper x of- Nothing -> fail [i|'${x}' is not an UpperChar.|]+ Nothing -> fail $ show x <> " is not an UpperChar." Just z -> conE . mkName $ show z - expQ xs@(_ : _) = fail [i|upperCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "upperCharQ required a Char, but a String is specified: " <> xs -- | '[a-z]'@@ -269,10 +268,10 @@ expQ [] = fail "lowerCharQ required a Char, but nothign is specified." expQ (x : []) = case charToLower x of- Nothing -> fail [i|'${x}' is not a LowerChar.|]+ Nothing -> fail $ show x <> " is not a LowerChar." Just z -> conE . mkName $ show z - expQ xs@(_ : _) = fail [i|lowerCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "lowerCharQ required a Char, but a String is specified: " <> xs -- | '[0-9]'@@ -331,16 +330,16 @@ expQ [] = fail "digitCharQ required a Char, but nothign is specified." expQ (x : []) = case charToDigit x of- Nothing -> fail [i|'${x}' is not a DigitChar.|]+ Nothing -> fail $ show x <> " is not a DigitChar." Just z -> conE . mkName $ show z - expQ xs@(_ : _) = fail [i|digitCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "digitCharQ required a Char, but a String is specified: " <> xs -- | -- '[a-zA-Z0-9_]' ----- Please see 'Snake'.+-- Please see 'Data.String.Cases.Snake'. data SnakeChar = SnakeUnderscore -- ^ _ | SnakeAlphaNum AlphaNumChar -- ^ [a-zA-Z0-9] deriving (Show, Eq)@@ -384,19 +383,19 @@ expQ [] = fail "snakeCharQ required a Char, but nothign is specified." expQ (x : []) = case charToSnake x of- Nothing -> fail [i|'${x}' is not a SnakeChar.|]+ Nothing -> fail $ show x <> " is not a SnakeChar." Just SnakeUnderscore -> conE $ mkName "SnakeUnderscore" Just (SnakeAlphaNum _) -> (ConE (mkName "SnakeAlphaNum") `AppE`) <$> (quoteExp alphaNumCharQ) [x] - expQ xs@(_ : _) = fail [i|snakeCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "snakeCharQ required a Char, but a String is specified: " <> xs -- | -- '[a-zA-Z_]' ----- Please see 'Snake'.+-- Please see 'Data.String.Cases.Snake'. data SnakeHeadChar = SnakeHeadUnderscore | SnakeHeadAlpha AlphaChar deriving (Show, Eq)@@ -437,19 +436,19 @@ expQ [] = fail "snakeHeadCharQ required a Char, but nothign is specified." expQ (x : []) = case charToSnakeHead x of- Nothing -> fail [i|'${x}' is not a SnakeHeadChar.|]+ Nothing -> fail $ show x <> " is not a SnakeHeadChar." Just SnakeHeadUnderscore -> conE $ mkName "SnakeHeadUnderscore" Just (SnakeHeadAlpha _) -> (ConE (mkName "SnakeHeadAlpha") `AppE`) <$> (quoteExp alphaCharQ) [x] - expQ xs@(_ : _) = fail [i|snakeHeadCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "snakeHeadCharQ required a Char, but a String is specified: " <> xs -- | -- '[A-Z_]' ----- Please sese 'UpperSnake'.+-- Please sese 'Data.String.Cases.UpperSnake'. data UpperSnakeHeadChar = UpperSnakeHeadUnderscore -- ^ _ | UpperSnakeHeadUpper UpperChar -- ^ [A-Z] deriving (Show, Eq)@@ -485,19 +484,19 @@ expQ (x : []) = case charToUpperSnakeHead x of Nothing ->- fail [i|'${x}' is not a UpperSnakeHeadChar.|]+ fail $ show x <> " is not a UpperSnakeHeadChar." Just UpperSnakeHeadUnderscore -> conE $ mkName "UpperSnakeHeadUnderscore" Just (UpperSnakeHeadUpper _) -> (ConE (mkName "UpperSnakeHeadUpper") `AppE`) <$> (quoteExp upperCharQ) [x] - expQ xs@(_ : _) = fail [i|upperSnakeHeadCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "upperSnakeHeadCharQ required a Char, but a String is specified: " <> xs -- | -- '[A-Z0-9_]' ----- Please see 'Snake'.+-- Please see 'Data.String.Cases.UpperSnake'. data UpperSnakeChar = UpperSnakeUnderscore -- ^ _ | UpperSnakeUpper UpperChar -- ^ [A-Z] | UpperSnakeDigit DigitChar -- ^ [0-9]@@ -539,7 +538,7 @@ expQ (x : []) = case charToUpperSnake x of Nothing ->- fail [i|'${x}' is not a UpperSnakeChar.|]+ fail $ show x <> " is not a UpperSnakeChar." Just UpperSnakeUnderscore -> conE $ mkName "UpperSnakeUnderscore" Just (UpperSnakeUpper _) ->@@ -547,4 +546,4 @@ Just (UpperSnakeDigit _) -> (ConE (mkName "UpperSnakeDigit") `AppE`) <$> (quoteExp digitCharQ) [x] - expQ xs@(_ : _) = fail [i|upperSnakeCharQ required a Char, but a String is specified: ${xs}|]+ expQ xs@(_ : _) = fail $ "upperSnakeCharQ required a Char, but a String is specified: " <> xs
src/Data/String/Cases.hs view
@@ -157,7 +157,7 @@ -- | -- Simular to 'nonEmptyQ',--- but naming outsides of 'Snake' will be rejected.+-- but naming outsides of 'Data.String.Cases.Snake' will be rejected. -- -- >>> [snakeQ|foo_bar|] -- Snake (SnakeHeadAlpha (AlphaLower F_)) [SnakeAlphaNum (AlphaNumAlpha (AlphaLower O_)),SnakeAlphaNum (AlphaNumAlpha (AlphaLower O_)),SnakeUnderscore,SnakeAlphaNum (AlphaNumAlpha (AlphaLower B_)),SnakeAlphaNum (AlphaNumAlpha (AlphaLower A_)),SnakeAlphaNum (AlphaNumAlpha (AlphaLower R_))]@@ -183,7 +183,7 @@ pure $ ConE (mkName "Snake") `AppE` z `AppE` ListE zs --- | A kind of Snake. "[A-Z_][A-Z0-9_]*"+-- | A kind of 'Data.String.Cases'. @[A-Z_][A-Z0-9_]*@ data UpperSnake = UpperSnake UpperSnakeHeadChar [UpperSnakeChar] deriving (Show, Eq)