-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Support the latest versions of GHC #289
Conversation
* add ghc 9.2, 9.4 to ci * make copyright in license files agree with copyright in cabal files * move library files to src/ * fourmolu and hlint * use Cabal 3.0 * remove most CPP
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
|
||
module Web.Scotty.Internal.Types where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to src/Web/Scotty/Internal/Types.hs
, GeneralizedNewtypeDeriving | ||
#-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,4 +1,5 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,10 +1,11 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,23 +1,24 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
-- This examples requires you to: cabal install cookie | |||
-- and: cabal install blaze-html | |||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,4 +1,6 @@ | |||
{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving #-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,15 +1,16 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,4 +1,5 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -10,30 +10,34 @@ module Main where | |||
import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, asks, lift, runReaderT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
Category: Web | ||
Stability: experimental | ||
Build-type: Simple | ||
Cabal-version: >= 1.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Cabal 3.0
Build-type: Simple | ||
Cabal-version: >= 1.10 | ||
Description: Example programs using @scotty@ | ||
tested-with: GHC == 7.6.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added GHC 9.4, 9.2. Dropped GHC <8.10
location: https://github.com/scotty-web/scotty | ||
subdir: examples | ||
|
||
common examples-common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put Scotty and GHC boot libs in a common build-depends
. This adds some spurious build-depends
to some of the examples, but I figure it's a moot point as there's not really going to be a Haskell distribution that doesn't include the GHC boot libs already.
@@ -1,4 +1,5 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
@@ -1,4 +1,5 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Main (main) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional changes.
Category: Web | ||
Stability: experimental | ||
Build-type: Simple | ||
Cabal-version: >= 1.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Cabal 3.0
[WAI] <http://hackage.haskell.org/package/wai> | ||
. | ||
[Warp] <http://hackage.haskell.org/package/warp> | ||
tested-with: GHC == 7.6.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add GHCs 9.4, 9.2. Drop GHCs <8.10
@@ -64,81 +63,87 @@ Extra-source-files: | |||
examples/static/jquery-json.js | |||
examples/uploads/.keep | |||
|
|||
Library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmetic refactor, to reduce future diff noise
Web.Scotty.Route | ||
Web.Scotty.Util | ||
default-language: Haskell2010 | ||
build-depends: aeson >= 0.6.2.1 && < 2.2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kinda skeptical that these bounds really make a lot of sense. How were they calculated?
In the PR, I only bound base
and leave the rest up to Cabal. To compensate for lack of bounds in the cabal file, I've included freeze files from some successful builds with a variety of GHCs. If people are adamant about it, I can use the feeze files to compute version bounds.
@@ -7,46 +6,99 @@ | |||
-- the comments on each of these functions for more information. | |||
module Web.Scotty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional change.
(e,r) <- flip MS.runStateT def | ||
$ flip runReaderT env | ||
$ runExceptT | ||
$ runAM | ||
$ action `catchError` (defH h) | ||
(e, r) <- | ||
flip MS.runStateT def $ | ||
flip runReaderT env $ | ||
runExceptT $ | ||
runAM $ | ||
action `catchError` defH h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't necessarily agree with the code formatter, but I think it's useful for reducing future diff noise. I'm open to rolling back the formatting changes if people disagree.
parseParam t = if t' == T.toCaseFold "true" | ||
then Right True | ||
else if t' == T.toCaseFold "false" | ||
then Right False | ||
else Left "parseParam Bool: no parse" | ||
where t' = T.toCaseFold t | ||
parseParam t | ||
| t' == true = Right True | ||
| t' == false = Right False | ||
| otherwise = Left "parseParam Bool: no parse" | ||
where | ||
t' = T.toCaseFold t | ||
true = T.toCaseFold "true" | ||
false = T.toCaseFold "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cleaned up this block by changing nested if/then to guards, and I factored out true
and false
so that a sufficiently-advanced compiler could float them if it wanted.
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
|
||
module Web.Scotty.Route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- remove legacy CPP
- Code formatter/linter.
@@ -11,84 +12,145 @@ | |||
-- the comments on each of these functions for more information. | |||
module Web.Scotty.Trans |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional change.
@@ -12,19 +12,18 @@ module Web.Scotty.Util | |||
, readRequestBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter/linter. No functional change.
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
|
||
module Web.Scotty.Action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove legacy CPP.
- Code formatter/linter.
it "stops the execution of an action" $ do | ||
get "/scotty" `shouldRespondWith` 400 | ||
|
||
-- Skip these tests on Windows, since Unix sockets are not available | ||
#if !defined(mingw32_HOST_OS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved some things that were top-level and nested them into the test block. Reads better with the CPP that way.
{-# LANGUAGE OverloadedStrings, CPP #-} | ||
{-# LANGUAGE CPP #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Web.ScottySpec (main, spec) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor functional change by moving some helpers from top-level into a let
bind. This looks like a huge diff, but set github to ignore whitespace, as the changes are mostly indentation.
deriving newtype (Functor, Applicative, Monad, MonadIO) | ||
deriving (Semigroup, Monoid) via (Ap (ActionT e m) a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deriving Semigroup
, Monoid
, and Monad
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this rule out old GHCs? or are we dropping them (which is also fine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop ghc pre 8.10 from ci
I suppose this is intentional
instance (Monad m, ScottyError e) => Fail.MonadFail (ActionT e m) where | ||
fail = ActionT . throwError . stringError | ||
|
||
instance (Monad m, ScottyError e) => Alternative (ActionT e m) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved implementations from MonadPlus
instance to Alternative
instance.
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module Web.Scotty.Internal.Types where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- moved from ./Web/Scotty/Internal/Types.hs.
- remove CPP
- derive (functionally compatible) instances instead of writing them
It might be too late, but it would be nice to separate code style changes at least |
@fumieval good call. i can easily split them out :-) |
Hi @friedbrice , would you be able to move this forward so we do one last review and merge? Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to review it all but eventually LGTM.
For the future let's not have formatting PRs mixed with code changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@friedbrice is this file necessary?
license: BSD-3-Clause | ||
license-file: LICENSE | ||
author: Andrew Farmer <[email protected]> | ||
maintainer: Daniel Brice <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are other maintainers too at present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I'm not able to fix the conflicts so I cannot merge these changes.
Let's have separate PRs for linting and functional changes in the future. |
This is a tentative PR. I'd like to merge it, but I'm not adamant. This PR eliminates almost all CPP, closing #252. (Some CPP is kept around for gating certain tests by platform support.)
So, I'd like to tackle some of the Issues, such as #262, #258, and #272, and I would need to smooth out and simplify project maintenance before doing so.
I'd like to hear what thoughts @scotty-web/admins, @fumieval, @RyanGlScott, and other interested parties have about the following changes.