packages feed

cases 0.1.0 → 0.1.1

raw patch · 3 files changed

+33/−85 lines, 3 filesdep +base-preludedep −mtldep ~attoparsecdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: base-prelude

Dependencies removed: mtl

Dependency ranges changed: attoparsec, base

API changes (from Hackage documentation)

Files

cases.cabal view
@@ -1,11 +1,11 @@ name:   cases version:-  0.1.0+  0.1.1 synopsis:-  A converter for spinal, snake and camel case+  A converter for spinal, snake and camel cases description:-  A parser-based converter library for spinal, snake and camel case.+  A parser-based converter library for spinal, snake and camel cases. category:   Text homepage:@@ -43,16 +43,10 @@   exposed-modules:     Cases   build-depends:-    -- data:-    attoparsec >= 0.10 && < 0.12,+    attoparsec >= 0.10 && < 0.13,     text,-    -- control:-    mtl,-    -- debugging:     loch-th == 0.2.*,-    placeholders == 0.1.*,-    -- general:-    base >= 4.5 && < 5+    base-prelude >= 0.1.4 && < 0.2   default-extensions:     Arrows     BangPatterns
library/Cases.hs view
@@ -21,8 +21,7 @@  import Cases.Prelude hiding (Word) import qualified Data.Attoparsec.Text as A-import qualified Data.Text as TS-import qualified Data.Char as C+import qualified Data.Text as T   -- * Part@@ -30,12 +29,12 @@  -- | A parsed info and a text of a part. data Part = -  Word Case TS.Text |-  Digits TS.Text+  Word Case T.Text |+  Digits T.Text  data Case = Title | Upper | Lower -partToText :: Part -> TS.Text+partToText :: Part -> T.Text partToText = \case   Word _ t -> t   Digits t -> t@@ -45,24 +44,24 @@ -------------------------  upperParser :: A.Parser Part-upperParser = Word Upper <$> TS.pack <$> A.many1 char where+upperParser = Word Upper <$> T.pack <$> A.many1 char where   char = do-    c <- A.satisfy C.isUpper-    ok <- maybe True (not . C.isLower) <$> A.peekChar+    c <- A.satisfy isUpper+    ok <- maybe True (not . isLower) <$> A.peekChar     if ok       then return c       else empty  lowerParser :: A.Parser Part-lowerParser = Word Lower <$> (A.takeWhile1 C.isLower)+lowerParser = Word Lower <$> (A.takeWhile1 isLower)  titleParser :: A.Parser Part-titleParser = Word Title <$> (TS.cons <$> headChar <*> remainder) where-  headChar = A.satisfy C.isUpper-  remainder = A.takeWhile1 C.isLower+titleParser = Word Title <$> (T.cons <$> headChar <*> remainder) where+  headChar = A.satisfy isUpper+  remainder = A.takeWhile1 isLower  digitsParser :: A.Parser Part-digitsParser = Digits <$> (A.takeWhile1 C.isDigit)+digitsParser = Digits <$> (A.takeWhile1 isDigit)  partParser :: A.Parser Part partParser = titleParser <|> upperParser <|> lowerParser <|> digitsParser@@ -82,7 +81,7 @@  type Folder r = r -> Part -> r -type Delimiter = Folder (Maybe TS.Text)+type Delimiter = Folder (Maybe T.Text)  spinal :: Delimiter spinal = @@ -111,10 +110,10 @@ lower = \case   Word c t -> Word Lower t' where     t' = case c of-      Title -> TS.uncons t |> \case+      Title -> T.uncons t |> \case         Nothing -> t-        Just (h, t) -> TS.cons (C.toLower h) t-      Upper -> TS.toLower t+        Just (h, t) -> T.cons (toLower h) t+      Upper -> T.toLower t       Lower -> t   p -> p @@ -122,11 +121,11 @@ upper = \case   Word c t -> Word Upper t' where     t' = case c of-      Title -> TS.uncons t |> \case+      Title -> T.uncons t |> \case         Nothing -> t-        Just (h, t) -> TS.cons h (TS.toUpper t)+        Just (h, t) -> T.cons h (T.toUpper t)       Upper -> t-      Lower -> TS.toUpper t+      Lower -> T.toUpper t   p -> p  title :: CaseTransformer@@ -134,12 +133,12 @@   Word c t -> Word Title t' where     t' = case c of       Title -> t-      Upper -> TS.uncons t |> \case+      Upper -> T.uncons t |> \case         Nothing -> t  -        Just (h, t) -> TS.cons (C.toUpper h) (TS.toLower t)-      Lower -> TS.uncons t |> \case+        Just (h, t) -> T.cons (toUpper h) (T.toLower t)+      Lower -> T.uncons t |> \case         Nothing -> t-        Just (h, t) -> TS.cons (C.toUpper h) t+        Just (h, t) -> T.cons (toUpper h) t   p -> p  @@ -151,7 +150,7 @@ -- produce a new text using case transformation and delimiter functions. --  -- Note: to skip case transformation use the 'id' function.-process :: CaseTransformer -> Delimiter -> TS.Text -> TS.Text+process :: CaseTransformer -> Delimiter -> T.Text -> T.Text process tr fo =    fromMaybe "" .   either ($bug . ("Parse failure: " <>)) id .@@ -161,14 +160,14 @@ -- Transform an arbitrary text into a lower spinal case. --  -- Same as @('process' 'lower' 'spinal')@.-spinalize :: TS.Text -> TS.Text+spinalize :: T.Text -> T.Text spinalize = process lower spinal  -- | -- Transform an arbitrary text into a lower snake case. --  -- Same as @('process' 'lower' 'snake')@.-snakify :: TS.Text -> TS.Text+snakify :: T.Text -> T.Text snakify = process lower snake  -- |@@ -176,6 +175,6 @@ -- while preserving the case of the first character. --  -- Same as @('process' 'id' 'camel')@.-camelize :: TS.Text -> TS.Text+camelize :: T.Text -> T.Text camelize = process id camel 
library/Cases/Prelude.hs view
@@ -2,7 +2,6 @@ (    module Exports, -  traceM,   bug,   bottom, @@ -15,55 +14,11 @@  -- base --------------------------import Prelude as Exports hiding (concat, foldr, mapM_, sequence_, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, mapM, sequence, FilePath, id, (.))-import Control.Monad as Exports hiding (mapM_, sequence_, forM_, msum, mapM, sequence, forM)-import Control.Applicative as Exports-import Control.Arrow as Exports hiding (left, right)-import Control.Category as Exports-import Data.Monoid as Exports-import Data.Foldable as Exports-import Data.Traversable as Exports hiding (for)-import Data.Maybe as Exports-import Data.Either as Exports-import Data.List as Exports hiding (concat, foldr, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, find, maximumBy, minimumBy, mapAccumL, mapAccumR, foldl')-import Data.Tuple as Exports-import Data.Function as Exports hiding ((.), id)-import Data.Ord as Exports (Down(..))-import Data.String as Exports-import Data.Int as Exports-import Data.Word as Exports-import Data.Ratio as Exports-import Data.Fixed as Exports-import Data.Ix as Exports-import Data.Data as Exports-import Text.Read as Exports (readMaybe, readEither)-import Control.Exception as Exports hiding (tryJust, try, assert)-import Control.Concurrent as Exports hiding (yield)-import System.Mem as Exports-import System.Mem.StableName as Exports-import System.Timeout as Exports-import System.Exit as Exports-import System.IO.Unsafe as Exports-import System.IO as Exports (Handle, hClose)-import System.IO.Error as Exports-import Unsafe.Coerce as Exports-import GHC.Generics as Exports (Generic)-import GHC.IO.Exception as Exports-import Data.IORef as Exports-import Data.STRef as Exports-import Control.Monad.ST as Exports-import Debug.Trace as Exports hiding (traceM)---- placeholders---------------------------import Development.Placeholders as Exports+import BasePrelude as Exports  -- custom ------------------------- import qualified Debug.Trace.LocationTH--traceM :: (Monad m) => String -> m ()-traceM s = trace s $ return ()  bug = [e| $(Debug.Trace.LocationTH.failure) . (msg <>) |]   where