diff --git a/lisa.cabal b/lisa.cabal index c9e7a25..942e96b 100644 --- a/lisa.cabal +++ b/lisa.cabal @@ -31,6 +31,7 @@ library Paths_lisa hs-source-dirs: src + ghc-options: -W build-depends: Spock >=0.14 , aeson >=2.0 diff --git a/package.yaml b/package.yaml index 3aa6e6b..24adb01 100644 --- a/package.yaml +++ b/package.yaml @@ -29,6 +29,8 @@ dependencies: library: source-dirs: src + ghc-options: + - -W executables: lisa-exe: diff --git a/src/Lisa/Squeak.hs b/src/Lisa/Squeak.hs index 069d203..9230f4e 100644 --- a/src/Lisa/Squeak.hs +++ b/src/Lisa/Squeak.hs @@ -7,11 +7,11 @@ module Lisa.Squeak where import Control.Applicative ((<|>)) import Control.Monad.IO.Class (MonadIO, liftIO) -import Data.Aeson (FromJSON(parseJSON), FromJSONKey(fromJSONKey), Options(fieldLabelModifier), ToJSON(toJSON), Value, (.:), (.:?), (.=), defaultOptions, genericParseJSON, genericToJSON, object, withObject) +import Data.Aeson (FromJSON(parseJSON), Options(fieldLabelModifier), ToJSON(toJSON), (.:), (.=), defaultOptions, genericParseJSON, genericToJSON, object, withObject) import Data.Text (Text) import Data.Time.Calendar (Day) import GHC.Generics (Generic) -import Network.HTTP.Req (Option, Scheme(..), POST(..), ReqBodyJson(..), Req, Scheme, Url, defaultHttpConfig, http, https, port, jsonResponse, responseBody, req, runReq) +import Network.HTTP.Req (Option, Scheme(..), POST(..), ReqBodyJson(..), Url, defaultHttpConfig, http, port, jsonResponse, responseBody, req, runReq) import qualified Data.Char as Char @@ -105,9 +105,11 @@ removePrefixModifier prefix = lowercaseFirst . stripPrefix prefix stripPrefix [] word = word stripPrefix (p:ps) (c:cs) | p == c = stripPrefix ps cs - | otherwise = error $ "Invalid prefix " ++ ps ++ " (" ++ prefix ++ ") for key " ++ cs + | otherwise = error $ "Invalid prefix " ++ (p:ps) ++ " (" ++ prefix ++ ") for key " ++ (c:cs) stripPrefix _ [] = error $ "Prefix " ++ prefix ++ " is too long" + lowercaseFirst (c:cs) = Char.toLower c : cs + lowercaseFirst [] = error $ "Prefix " ++ prefix ++ " ate all my input" removePrefixOpts prefix = defaultOptions { fieldLabelModifier = removePrefixModifier prefix }