appc 0.0.3 → 0.0.4
raw patch · 2 files changed
+30/−1 lines, 2 files
Files
- appc.cabal +2/−1
- src/Data/AppContainer/TH.hs +28/−0
appc.cabal view
@@ -1,5 +1,5 @@ name: appc-version: 0.0.3+version: 0.0.4 license: MIT license-file: LICENSE author: Tomas Carnecky@@ -18,6 +18,7 @@ exposed-modules: Data.AppContainer,+ Data.AppContainer.TH Data.AppContainer.Types build-depends:
+ src/Data/AppContainer/TH.hs view
@@ -0,0 +1,28 @@+module Data.AppContainer.TH+ ( deriveJSON+ , deriveToJSON+ , deriveJSONOptions+ , FromJSON(..)+ , ToJSON(..)+ ) where+++import Control.Monad++import Data.Char++import Data.Aeson+import Data.Aeson.TH+++dropPrefix :: String -> String -> String+dropPrefix prefix x = toLower (head rest) : tail rest+ where rest = drop (length prefix) x+++-- FIXME: Should dasherize and drop the prefix from the constructor as well!+deriveJSONOptions :: String -> Options+deriveJSONOptions prefix = defaultOptions+ { fieldLabelModifier = dropPrefix prefix+ , constructorTagModifier = map toLower+ }