Add -W flag to package.yaml

This commit is contained in:
Paul Brinkmeier 2022-08-25 21:51:32 +02:00
parent f8bfff0538
commit 43ca3dfbf6
3 changed files with 8 additions and 3 deletions

View File

@ -31,6 +31,7 @@ library
Paths_lisa Paths_lisa
hs-source-dirs: hs-source-dirs:
src src
ghc-options: -W
build-depends: build-depends:
Spock >=0.14 Spock >=0.14
, aeson >=2.0 , aeson >=2.0

View File

@ -29,6 +29,8 @@ dependencies:
library: library:
source-dirs: src source-dirs: src
ghc-options:
- -W
executables: executables:
lisa-exe: lisa-exe:

View File

@ -7,11 +7,11 @@ module Lisa.Squeak where
import Control.Applicative ((<|>)) import Control.Applicative ((<|>))
import Control.Monad.IO.Class (MonadIO, liftIO) 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.Text (Text)
import Data.Time.Calendar (Day) import Data.Time.Calendar (Day)
import GHC.Generics (Generic) 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 import qualified Data.Char as Char
@ -105,9 +105,11 @@ removePrefixModifier prefix = lowercaseFirst . stripPrefix prefix
stripPrefix [] word = word stripPrefix [] word = word
stripPrefix (p:ps) (c:cs) stripPrefix (p:ps) (c:cs)
| p == c = stripPrefix ps 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" stripPrefix _ [] = error $ "Prefix " ++ prefix ++ " is too long"
lowercaseFirst (c:cs) = Char.toLower c : cs lowercaseFirst (c:cs) = Char.toLower c : cs
lowercaseFirst [] = error $ "Prefix " ++ prefix ++ " ate all my input"
removePrefixOpts prefix = defaultOptions { fieldLabelModifier = removePrefixModifier prefix } removePrefixOpts prefix = defaultOptions { fieldLabelModifier = removePrefixModifier prefix }