cases 0.1.4.3 → 0.1.4.4
raw patch · 2 files changed
+64/−50 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Cases: type Delimiter = Folder (Maybe Text)
+ Cases: data Delimiter
Files
- cases.cabal +43/−37
- library/Cases.hs +21/−13
cases.cabal view
@@ -1,28 +1,26 @@ cabal-version: 3.0-name: cases-version: 0.1.4.3-synopsis: A converter for spinal, snake and camel cases+name: cases+version: 0.1.4.4+synopsis: A converter for spinal, snake and camel cases description: A parser-based converter library for spinal, snake and camel cases. -category: Text-homepage: https://github.com/nikita-volkov/cases -bug-reports: https://github.com/nikita-volkov/cases/issues -author: Nikita Volkov <nikita.y.volkov@mail.ru>-maintainer: Nikita Volkov <nikita.y.volkov@mail.ru>-copyright: (c) 2014, Nikita Volkov-license: MIT-license-file: LICENSE+category: Text+homepage: https://github.com/nikita-volkov/cases+bug-reports: https://github.com/nikita-volkov/cases/issues+author: Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer: Nikita Volkov <nikita.y.volkov@mail.ru>+copyright: (c) 2014, Nikita Volkov+license: MIT+license-file: LICENSE source-repository head- type: git- location: git://github.com/nikita-volkov/cases.git+ type: git+ location: https://github.com/nikita-volkov/cases common base- default-language: Haskell2010+ default-language: Haskell2010 default-extensions:- NoImplicitPrelude- NoMonomorphismRestriction Arrows BangPatterns BlockArguments@@ -41,11 +39,12 @@ GADTs GeneralizedNewtypeDeriving LambdaCase- LambdaCase LiberalTypeSynonyms MagicHash MultiParamTypeClasses MultiWayIf+ NoImplicitPrelude+ NoMonomorphismRestriction OverloadedStrings ParallelListComp PatternGuards@@ -61,33 +60,40 @@ UnboxedTuples library- import: base- hs-source-dirs: library+ import: base+ hs-source-dirs: library exposed-modules: Cases- other-modules: Cases.Prelude+ other-modules: Cases.Prelude build-depends:- , attoparsec >=0.13 && <0.15- , base >=4.11 && <5- , text >=1 && <3+ attoparsec >=0.13 && <0.15,+ base >=4.11 && <5,+ text >=1 && <3, test-suite api-tests- import: base- type: exitcode-stdio-1.0+ import: base+ type: exitcode-stdio-1.0 hs-source-dirs: api-tests- main-is: Main.hs- ghc-options: -threaded -with-rtsopts=-N+ main-is: Main.hs+ ghc-options:+ -threaded+ -with-rtsopts=-N+ build-depends:- , cases- , hspec >=2.11 && <3- , rerebase >=1 && <2+ cases,+ hspec >=2.11 && <3,+ rerebase >=1 && <2, benchmark benchmark- import: base- type: exitcode-stdio-1.0+ import: base+ type: exitcode-stdio-1.0 hs-source-dirs: benchmark- main-is: Benchmark.hs- ghc-options: -O2 -threaded -with-rtsopts=-N+ main-is: Benchmark.hs+ ghc-options:+ -O2+ -threaded+ -with-rtsopts=-N+ build-depends:- , cases- , criterion >=1.6.3 && <2- , rerebase >=1 && <2+ cases,+ criterion >=1.6.3 && <2,+ rerebase >=1 && <2,
library/Cases.hs view
@@ -81,30 +81,38 @@ type Folder r = r -> Part -> r -type Delimiter = Folder (Maybe T.Text)+newtype Delimiter = Delimiter (Maybe T.Text -> Part -> Maybe T.Text) spinal :: Delimiter spinal =- (. partToText)- . fmap Just- . maybe id (\l r -> l <> "-" <> r)+ Delimiter+ ( (. partToText)+ . fmap Just+ . maybe id (\l r -> l <> "-" <> r)+ ) snake :: Delimiter snake =- (. partToText)- . fmap Just- . maybe id (\l r -> l <> "_" <> r)+ Delimiter+ ( (. partToText)+ . fmap Just+ . maybe id (\l r -> l <> "_" <> r)+ ) whitespace :: Delimiter whitespace =- (. partToText)- . fmap Just- . maybe id (\l r -> l <> " " <> r)+ Delimiter+ ( (. partToText)+ . fmap Just+ . maybe id (\l r -> l <> " " <> r)+ ) camel :: Delimiter camel =- fmap Just- . maybe partToText (\l r -> l <> partToText (title r))+ Delimiter+ ( fmap Just+ . maybe partToText (\l r -> l <> partToText (title r))+ ) -- * CaseTransformers @@ -160,7 +168,7 @@ -- -- Note: to skip case transformation use the 'id' function. process :: CaseTransformer -> Delimiter -> T.Text -> T.Text-process tr fo =+process tr (Delimiter fo) = fromMaybe "" . either (error . ("Parse failure: " <>)) id . A.parseOnly (partsParser $ (. tr) . fo)