Skip to content

Commit

Permalink
Compile with -Wall -Werror
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 5, 2017
1 parent 07147f4 commit 3dc2d10
Show file tree
Hide file tree
Showing 67 changed files with 317 additions and 185 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -178,9 +178,9 @@ script:
if [ `uname` = "Darwin" ]
then
# Use slightly less intensive options on OS X due to Travis timeouts
stack --no-terminal $ARGS test --fast
stack --no-terminal $ARGS test --fast --pedantic
else
stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps
stack --no-terminal $ARGS test --bench --no-run-benchmarks --haddock --no-haddock-deps --pedantic
fi
;;
cabal)
Expand Down
6 changes: 3 additions & 3 deletions yesod-auth-oauth/Yesod/Auth/OAuth.hs
Expand Up @@ -10,7 +10,7 @@ module Yesod.Auth.OAuth
, tumblrUrl
, module Web.Authenticate.OAuth
) where
import Control.Applicative ((<$>), (<*>))
import Control.Applicative as A ((<$>), (<*>))
import Control.Arrow ((***))
import Control.Exception.Lifted
import Control.Monad.IO.Class
Expand Down Expand Up @@ -66,8 +66,8 @@ authOAuth oauth mkCreds = AuthPlugin name dispatch login
]
else do
(verifier, oaTok) <-
runInputGet $ (,) <$> ireq textField "oauth_verifier"
<*> ireq textField "oauth_token"
runInputGet $ (,) A.<$> ireq textField "oauth_verifier"
A.<*> ireq textField "oauth_token"
return $ Credential [ ("oauth_verifier", encodeUtf8 verifier)
, ("oauth_token", encodeUtf8 oaTok)
, ("oauth_token_secret", encodeUtf8 tokSec)
Expand Down
2 changes: 1 addition & 1 deletion yesod-auth/Yesod/Auth.hs
Expand Up @@ -227,7 +227,7 @@ class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage
-- This is an experimental API that is not broadly used throughout the yesod-auth code base
runHttpRequest :: Request -> (Response BodyReader -> HandlerT master IO a) -> HandlerT master IO a
runHttpRequest req inner = do
man <- authHttpManager <$> getYesod
man <- authHttpManager Control.Applicative.<$> getYesod
HandlerT $ \t -> withResponse req man $ \res -> unHandlerT (inner res) t

{-# MINIMAL loginDest, logoutDest, (authenticate | getAuthId), authPlugins, authHttpManager #-}
Expand Down
32 changes: 16 additions & 16 deletions yesod-auth/Yesod/Auth/Email.hs
Expand Up @@ -131,8 +131,7 @@ import Data.Time (addUTCTime, getCurrentTime)
import Safe (readMay)
import System.IO.Unsafe (unsafePerformIO)
import qualified Text.Email.Validate
import Network.HTTP.Types.Status (status400)
import Data.Aeson.Types (Parser(..), Result(..), parseMaybe, withObject, (.:?))
import Data.Aeson.Types (Parser, Result(..), parseMaybe, withObject, (.:?))
import Data.Maybe (isJust, isNothing, fromJust)

loginR, registerR, forgotPasswordR, setpassR :: AuthRoute
Expand Down Expand Up @@ -170,10 +169,10 @@ data EmailCreds site = EmailCreds
, emailCredsEmail :: Email
}

data ForgotPasswordForm = ForgotPasswordForm { forgotEmail :: Text }
data PasswordForm = PasswordForm { passwordCurrent :: Text, passwordNew :: Text, passwordConfirm :: Text }
data UserForm = UserForm { email :: Text }
data UserLoginForm = UserLoginForm { loginEmail :: Text, loginPassword :: Text }
data ForgotPasswordForm = ForgotPasswordForm { _forgotEmail :: Text }
data PasswordForm = PasswordForm { _passwordCurrent :: Text, _passwordNew :: Text, _passwordConfirm :: Text }
data UserForm = UserForm { _userFormEmail :: Text }
data UserLoginForm = UserLoginForm { _loginEmail :: Text, _loginPassword :: Text }

class ( YesodAuth site
, PathPiece (AuthEmailId site)
Expand Down Expand Up @@ -352,7 +351,7 @@ emailLoginHandler toParent = do
(widget, enctype) <- liftWidgetT $ generateFormPost loginForm

[whamlet|
<form method="post" action="@{toParent loginR}">
<form method="post" action="@{toParent loginR}", enctype=#{enctype}>
<div id="emailLoginForm">
^{widget}
<div>
Expand All @@ -371,7 +370,8 @@ emailLoginHandler toParent = do
passwordMsg <- renderMessage' Msg.Password
(passwordRes, passwordView) <- mreq passwordField (passwordSettings passwordMsg) Nothing

let userRes = UserLoginForm <$> emailRes <*> passwordRes
let userRes = UserLoginForm Control.Applicative.<$> emailRes
Control.Applicative.<*> passwordRes
let widget = do
[whamlet|
#{extra}
Expand Down Expand Up @@ -603,21 +603,21 @@ postLoginR = do
, emailCredsEmail <$> mecreds
, emailCredsStatus <$> mecreds
) of
(Just aid, Just email, Just True) -> do
(Just aid, Just email', Just True) -> do
mrealpass <- lift $ getPassword aid
case mrealpass of
Nothing -> return Nothing
Just realpass -> return $ if isValidPass pass realpass
then Just email
then Just email'
else Nothing
_ -> return Nothing
let isEmail = Text.Email.Validate.isValid $ encodeUtf8 identifier
case maid of
Just email ->
Just email' ->
lift $ setCredsRedirect $ Creds
(if isEmail then "email" else "username")
email
[("verifiedEmail", email)]
email'
[("verifiedEmail", email')]
Nothing ->
loginErrorMessageI LoginR $
if isEmail
Expand All @@ -643,15 +643,15 @@ defaultSetPasswordHandler needOld = do
selectRep $ do
provideJsonMessage $ messageRender Msg.SetPass
provideRep $ lift $ authLayout $ do
(widget, enctype) <- liftWidgetT $ generateFormPost $ setPasswordForm needOld
(widget, enctype) <- liftWidgetT $ generateFormPost setPasswordForm
setTitleI Msg.SetPassTitle
[whamlet|
<h3>_{Msg.SetPass}
<form method="post" action="@{toParent setpassR}">
<form method="post" action="@{toParent setpassR}" enctype=#{enctype}>
^{widget}
|]
where
setPasswordForm needOld extra = do
setPasswordForm extra = do
(currentPasswordRes, currentPasswordView) <- mreq passwordField currentPasswordSettings Nothing
(newPasswordRes, newPasswordView) <- mreq passwordField newPasswordSettings Nothing
(confirmPasswordRes, confirmPasswordView) <- mreq passwordField confirmPasswordSettings Nothing
Expand Down
28 changes: 21 additions & 7 deletions yesod-auth/Yesod/Auth/GoogleEmail2.hs
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
Expand Down Expand Up @@ -59,7 +60,7 @@ import Yesod.Core (HandlerSite, HandlerT, MonadHandler,
lift, liftIO, lookupGetParam,
lookupSession, notFound, redirect,
setSession, whamlet, (.:),
addMessage, getYesod, authRoute,
addMessage, getYesod,
toHtml)


Expand All @@ -85,8 +86,9 @@ import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as TL
import Network.HTTP.Client (Manager, parseUrl, requestHeaders,
import Network.HTTP.Client (Manager, requestHeaders,
responseBody, urlEncodedBody)
import qualified Network.HTTP.Client as HTTP
import Network.HTTP.Client.Conduit (Request, bodyReaderSource)
import Network.HTTP.Conduit (http)
import Network.HTTP.Types (renderQueryText)
Expand Down Expand Up @@ -167,7 +169,7 @@ authPlugin storeToken clientID clientSecret =
return $ decodeUtf8
$ toByteString
$ fromByteString "https://accounts.google.com/o/oauth2/auth"
`mappend` renderQueryText True qs
`Data.Monoid.mappend` renderQueryText True qs

login tm = do
[whamlet|<a href=@{tm forwardUrl}>_{Msg.LoginGoogle}|]
Expand Down Expand Up @@ -206,7 +208,13 @@ authPlugin storeToken clientID clientSecret =

render <- getUrlRender

req' <- liftIO $ parseUrl "https://accounts.google.com/o/oauth2/token" -- FIXME don't hardcode, use: https://accounts.google.com/.well-known/openid-configuration
req' <- liftIO $
#if MIN_VERSION_http_client(0,4,30)
HTTP.parseUrlThrow
#else
HTTP.parseUrl
#endif
"https://accounts.google.com/o/oauth2/token" -- FIXME don't hardcode, use: https://accounts.google.com/.well-known/openid-configuration
let req =
urlEncodedBody
[ ("code", encodeUtf8 code)
Expand Down Expand Up @@ -264,7 +272,13 @@ getPerson manager token = parseMaybe parseJSON <$> (do

personValueRequest :: MonadIO m => Token -> m Request
personValueRequest token = do
req2' <- liftIO $ parseUrl "https://www.googleapis.com/plus/v1/people/me"
req2' <- liftIO $
#if MIN_VERSION_http_client(0,4,30)
HTTP.parseUrlThrow
#else
HTTP.parseUrl
#endif
"https://www.googleapis.com/plus/v1/people/me"
return req2'
{ requestHeaders =
[ ("Authorization", encodeUtf8 $ "Bearer " `mappend` accessToken token)
Expand All @@ -284,8 +298,8 @@ data Token = Token { accessToken :: Text

instance FromJSON Token where
parseJSON = withObject "Tokens" $ \o -> Token
<$> o .: "access_token"
<*> o .: "token_type"
Control.Applicative.<$> o .: "access_token"
Control.Applicative.<*> o .: "token_type"

--------------------------------------------------------------------------------
-- | Gender of the person
Expand Down
4 changes: 2 additions & 2 deletions yesod-auth/Yesod/Auth/Hardcoded.hs
Expand Up @@ -186,8 +186,8 @@ postLoginR :: (YesodAuthHardcoded master)
=> HandlerT Auth (HandlerT master IO) TypedContent
postLoginR =
do (username, password) <- lift (runInputPost
((,) <$> ireq textField "username"
<*> ireq textField "password"))
((,) Control.Applicative.<$> ireq textField "username"
Control.Applicative.<*> ireq textField "password"))
isValid <- lift (validatePassword username password)
if isValid
then lift (setCredsRedirect (Creds "hardcoded" username []))
Expand Down
4 changes: 2 additions & 2 deletions yesod-auth/Yesod/Auth/Message.hs
Expand Up @@ -87,7 +87,7 @@ englishMessage RegisterLong = "Register a new account"
englishMessage EnterEmail = "Enter your e-mail address below, and a confirmation e-mail will be sent to you."
englishMessage ConfirmationEmailSentTitle = "Confirmation e-mail sent"
englishMessage (ConfirmationEmailSent email) =
"A confirmation e-mail has been sent to " `mappend`
"A confirmation e-mail has been sent to " `Data.Monoid.mappend`
email `mappend`
"."
englishMessage AddressVerified = "Address verified, please set a new password"
Expand Down Expand Up @@ -464,7 +464,7 @@ finnishMessage LoginYahoo = "Kirjaudu Yahoo-tilillä"
finnishMessage Email = "Sähköposti"
finnishMessage UserName = "Käyttäjätunnus" -- FIXME by Google Translate "user name"
finnishMessage Password = "Salasana"
finnishMessage Password = "Current password"
finnishMessage CurrentPassword = "Current password"
finnishMessage Register = "Luo uusi"
finnishMessage RegisterLong = "Luo uusi tili"
finnishMessage EnterEmail = "Kirjoita alle sähköpostiosoitteesi, johon vahvistussähköposti lähetetään."
Expand Down
16 changes: 1 addition & 15 deletions yesod-auth/Yesod/PasswordStore.hs
Expand Up @@ -163,7 +163,7 @@ pbkdf2 password (SaltBS salt) c =
let hLen = 32
dkLen = hLen in go hLen dkLen
where
go hLen dkLen | dkLen > (2^32 - 1) * hLen = error "Derived key too long."
go hLen dkLen | dkLen > (2^(32 :: Int) - 1) * hLen = error "Derived key too long."
| otherwise =
let !l = ceiling ((fromIntegral dkLen / fromIntegral hLen) :: Double)
!r = dkLen - (l - 1) * hLen
Expand Down Expand Up @@ -413,17 +413,3 @@ modifySTRef' ref f = do
let x' = f x
x' `seq` writeSTRef ref x'
#endif

#if MIN_VERSION_bytestring(0, 10, 0)
toStrict :: BL.ByteString -> BS.ByteString
toStrict = BL.toStrict

fromStrict :: BS.ByteString -> BL.ByteString
fromStrict = BL.fromStrict
#else
toStrict :: BL.ByteString -> BS.ByteString
toStrict = BS.concat . BL.toChunks

fromStrict :: BS.ByteString -> BL.ByteString
fromStrict = BL.fromChunks . return
#endif
8 changes: 4 additions & 4 deletions yesod-bin/Build.hs
Expand Up @@ -11,7 +11,7 @@ module Build
, safeReadFile
) where

import Control.Applicative ((<|>), many, (<$>))
import Control.Applicative as App ((<|>), many, (<$>))
import qualified Data.Attoparsec.Text as A
import Data.Char (isSpace, isUpper)
import qualified Data.Text as T
Expand All @@ -28,7 +28,7 @@ import Control.Monad.Trans.Writer (WriterT, tell, execWriterT)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Trans.Class (lift)

import Data.Monoid (Monoid (mappend, mempty))
import Data.Monoid (Monoid (..))
import qualified Data.Map as Map
import qualified Data.Set as Set

Expand Down Expand Up @@ -77,7 +77,7 @@ getDeps hsSourceDirs = do
return $ (hss, fixDeps $ zip hss deps')

data AnyFilesTouched = NoFilesTouched | SomeFilesTouched
instance Monoid AnyFilesTouched where
instance Data.Monoid.Monoid AnyFilesTouched where
mempty = NoFilesTouched
mappend NoFilesTouched NoFilesTouched = mempty
mappend _ _ = SomeFilesTouched
Expand Down Expand Up @@ -201,7 +201,7 @@ determineDeps x = do
Left _ -> return []
Right r -> mapM go r >>= filterM (doesFileExist . snd) . concat
where
go (Just (StaticFiles fp, _)) = map ((,) AlwaysOutdated) <$> getFolderContents fp
go (Just (StaticFiles fp, _)) = map ((,) AlwaysOutdated) App.<$> getFolderContents fp
go (Just (Hamlet, f)) = return [(AlwaysOutdated, f)]
go (Just (Widget, f)) = return
[ (AlwaysOutdated, "templates/" ++ f ++ ".hamlet")
Expand Down
1 change: 1 addition & 0 deletions yesod-core/Yesod/Core/Class/Handler.hs
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} -- Because of ErrorT
module Yesod.Core.Class.Handler
( MonadHandler (..)
, MonadWidget (..)
Expand Down
14 changes: 7 additions & 7 deletions yesod-core/bench/widget.hs
Expand Up @@ -7,20 +7,16 @@ module Main where

import Criterion.Main
import Text.Hamlet
import Numeric (showInt)
import qualified Data.ByteString.Lazy as L
import qualified Text.Blaze.Html.Renderer.Utf8 as Utf8
import Data.Monoid (mconcat)
import Text.Blaze.Html5 (table, tr, td)
import Text.Blaze.Html (toHtml)
import Yesod.Core.Widget
import Control.Monad.Trans.Writer
import Control.Monad.Trans.RWS
import Data.Functor.Identity
import Yesod.Core.Types
import Data.Monoid
import Data.IORef
import Data.Int

main :: IO ()
main = defaultMain
[ bench "bigTable html" $ nf bigTableHtml bigTableData
, bench "bigTable hamlet" $ nf bigTableHamlet bigTableData
Expand All @@ -35,6 +31,7 @@ main = defaultMain
bigTableData = replicate rows [1..10]
{-# NOINLINE bigTableData #-}

bigTableHtml :: Show a => [[a]] -> Int64
bigTableHtml rows = L.length $ Utf8.renderHtml $ ($ id) [hamlet|
<table>
$forall row <- rows
Expand All @@ -43,6 +40,7 @@ bigTableHtml rows = L.length $ Utf8.renderHtml $ ($ id) [hamlet|
<td>#{show cell}
|]

bigTableHamlet :: Show a => [[a]] -> Int64
bigTableHamlet rows = L.length $ Utf8.renderHtml $ ($ id) [hamlet|
<table>
$forall row <- rows
Expand All @@ -51,6 +49,7 @@ bigTableHamlet rows = L.length $ Utf8.renderHtml $ ($ id) [hamlet|
<td>#{show cell}
|]

bigTableWidget :: Show a => [[a]] -> IO Int64
bigTableWidget rows = fmap (L.length . Utf8.renderHtml . ($ render)) (run [whamlet|
<table>
$forall row <- rows
Expand All @@ -64,6 +63,7 @@ bigTableWidget rows = fmap (L.length . Utf8.renderHtml . ($ render)) (run [whaml
(_, GWData { gwdBody = Body x }) <- w undefined
return x

bigTableBlaze t = L.length $ Utf8.renderHtml $ table $ mconcat $ map row t
bigTableBlaze :: Show a => [[a]] -> Int64
bigTableBlaze t = L.length $ Utf8.renderHtml $ table $ Data.Monoid.mconcat $ map row t
where
row r = tr $ mconcat $ map (td . toHtml . show) r
5 changes: 0 additions & 5 deletions yesod-core/test.hs

This file was deleted.

3 changes: 3 additions & 0 deletions yesod-core/test/Hierarchy.hs
Expand Up @@ -17,6 +17,9 @@ module Hierarchy
, toText
, Env (..)
, subDispatch
-- to avoid warnings
, deleteDelete2
, deleteDelete3
) where

import Test.Hspec
Expand Down

0 comments on commit 3dc2d10

Please sign in to comment.