Skip to content

Commit 9d509c4

Browse files
committed
Fix compilation and CI on GHC 8.6 & 8.8
* Backwards compatible handling of: - `MonadFail` changes (`fail` moved out of `Monad`) - `Semigroup` changes (re-exported from `Prelude`) * `happy` recently broke partial type signatures for parametrized productions (they were unsound). Thankfully, it turns out there was all along a better way to write type signatures for these productions. * Update CI scripts, testing new configurations...
1 parent c4dd601 commit 9d509c4

File tree

10 files changed

+61
-60
lines changed

10 files changed

+61
-60
lines changed

.travis.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ sudo: true
33

44
# Add new environments to the build here:
55
env:
6-
- GHCVER=7.10.3 CABALVER=1.22
7-
- GHCVER=8.0.2 CABALVER=1.24
8-
- GHCVER=8.2.2 CABALVER=2.0
9-
- GHCVER=8.4.1 CABALVER=head
6+
- GHCVER=8.0.2 CABALVER=3.0
7+
- GHCVER=8.2.2 CABALVER=3.0
8+
- GHCVER=8.4.4 CABALVER=3.0
9+
- GHCVER=8.6.5 CABALVER=3.0
10+
- GHCVER=8.8.1 CABALVER=3.0
1011
- GHCVER=head CABALVER=head
1112

1213
# Allow for develop branch to break
1314
matrix:
1415
allow_failures:
15-
- env: GHCVER=8.4.1 CABALVER=head
16+
- env: GHCVER=8.8.1 CABALVER=3.0
1617
- env: GHCVER=head CABALVER=head
1718

1819
# Manually install ghc and cabal
@@ -29,10 +30,7 @@ install:
2930
- echo $PATH
3031
- cabal --version
3132
- ghc --version
32-
- cabal install happy --constraint 'happy >= 1.19.8'
33-
- cabal install alex
34-
- cabal install --verbose --enable-tests
35-
- cabal configure
33+
- cabal configure --verbose --enable-tests
3634

3735
script:
3836
- cabal test

appveyor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ environment:
77
# - resolver: lts-6.35 # ghc-7.10.3
88
# - resolver: lts-7.24 # ghc-8.0.1
99
# - resolver: lts-9.21 # ghc-8.0.2
10-
- resolver: lts-10.7 # ghc-2.2.2
10+
- resolver: lts-11.22 # ghc-8.2.2
11+
- resolver: lts-12.14 # ghc-8.4.4
12+
- resolver: lts-14.4 # ghc-8.6.5
1113
- resolver: nightly
1214

1315
# Manually fetch stack
@@ -21,7 +23,7 @@ install:
2123

2224
# Install Happy and Alex first, before installing
2325
build_script:
24-
- stack --no-terminal install --resolver %resolver% happy-1.19.8
26+
- stack --no-terminal install --resolver %resolver% happy-1.19.12
2527
- stack --no-terminal install --resolver %resolver% alex
2628

2729
test_script:

language-rust.cabal

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ library
5656
Language.Rust.Data.InputStream
5757
if flag(enableQuasiquotes)
5858
exposed-modules: Language.Rust.Quote
59-
59+
6060
other-modules: Language.Rust.Parser.Literals
6161
Language.Rust.Parser.Reversed
6262
Language.Rust.Pretty.Resolve
@@ -65,6 +65,11 @@ library
6565
Language.Rust.Syntax.AST
6666
Language.Rust.Syntax.Token
6767

68+
-- Starting in 8.8, `MonadFailDesugaring` is default
69+
if impl(ghc < 8.8)
70+
default-extensions:
71+
MonadFailDesugaring
72+
6873
other-extensions: FlexibleContexts
6974
, FlexibleInstances
7075
, OverloadedStrings
@@ -79,13 +84,11 @@ library
7984
, BangPatterns
8085
, CPP
8186

82-
build-depends: base >=4.8 && <5.0
87+
build-depends: base >=4.9 && <5.0
8388
, prettyprinter >=1.0 && <2.0
8489
, transformers >=0.4 && <0.6
8590
, array >=0.5 && <0.6
8691
, deepseq >=1.1 && <1.5
87-
if impl(ghc < 8)
88-
build-depends: semigroups >=0.18
8992

9093
if flag(useByteStrings)
9194
cpp-options: -DUSE_BYTESTRING
@@ -128,15 +131,15 @@ test-suite rustc-tests
128131
other-modules: Diff
129132
DiffUtils
130133

131-
other-extensions: InstanceSigs
134+
other-extensions: InstanceSigs
132135
, OverloadedStrings
133136
, OverloadedLists
134137
, MultiParamTypeClasses
135138
, UnicodeSyntax
136139

137140
type: exitcode-stdio-1.0
138141
default-language: Haskell2010
139-
142+
140143
build-depends: process >=1.3
141144
, bytestring >=0.10
142145
, aeson >=0.11.0.0
@@ -151,8 +154,6 @@ test-suite rustc-tests
151154
, language-rust
152155
, base
153156
, prettyprinter >=1.1
154-
if impl(ghc < 8)
155-
build-depends: semigroups >=0.18
156157

157158
benchmark timing-benchmarks
158159
hs-source-dirs: bench/timing-benchmarks

src/Language/Rust/Data/Ident.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Data.Typeable ( Typeable )
2424
import Data.List ( foldl' )
2525
import Data.Char ( ord )
2626
import Data.String ( IsString(..) )
27-
import Data.Semigroup ( Semigroup(..) )
27+
import Data.Semigroup as Sem
2828

2929
-- | An identifier
3030
data Ident
@@ -57,7 +57,7 @@ instance Monoid Ident where
5757
mempty = mkIdent ""
5858

5959
-- | "Forgets" about whether either argument was raw
60-
instance Semigroup Ident where
60+
instance Sem.Semigroup Ident where
6161
Ident n1 _ _ <> Ident n2 _ _ = mkIdent (n1 <> n2)
6262

6363

src/Language/Rust/Data/Position.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import Data.Data ( Data )
4242
import Data.Typeable ( Typeable )
4343

4444
import Data.List.NonEmpty ( NonEmpty(..) )
45-
import Data.Monoid ( Monoid(..) )
46-
import Data.Semigroup ( Semigroup(..) )
45+
import Data.Monoid as Mon
46+
import Data.Semigroup as Sem
4747

4848

4949
-- | A position in a source file. The row and column information is kept only for its convenience
@@ -139,22 +139,22 @@ instance Show Span where
139139
subsetOf :: Span -> Span -> Bool
140140
Span l1 h1 `subsetOf` Span l2 h2 = minPos l1 l2 == l1 && maxPos h1 h2 == h2
141141

142-
-- | Convenience function lifting '<>' to work on all 'Located' things
142+
-- | Convenience function lifting 'Mon.<>' to work on all 'Located' things
143143
{-# INLINE (#) #-}
144144
(#) :: (Located a, Located b) => a -> b -> Span
145-
left # right = spanOf left <> spanOf right
145+
left # right = spanOf left Mon.<> spanOf right
146146

147147
-- | smallest covering 'Span'
148-
instance Semigroup Span where
148+
instance Sem.Semigroup Span where
149149
{-# INLINE (<>) #-}
150150
Span l1 h1 <> Span l2 h2 = Span (l1 `minPos` l2) (h1 `maxPos` h2)
151151

152-
instance Monoid Span where
152+
instance Mon.Monoid Span where
153153
{-# INLINE mempty #-}
154154
mempty = Span NoPosition NoPosition
155155

156156
{-# INLINE mappend #-}
157-
mappend = (<>)
157+
mappend = (Sem.<>)
158158

159159
-- | Pretty print a 'Span'
160160
prettySpan :: Span -> String
@@ -178,11 +178,11 @@ instance Applicative Spanned where
178178
pure x = Spanned x mempty
179179

180180
{-# INLINE (<*>) #-}
181-
Spanned f s1 <*> Spanned x s2 = Spanned (f x) (s1 <> s2)
181+
Spanned f s1 <*> Spanned x s2 = Spanned (f x) (s1 Sem.<> s2)
182182

183183
instance Monad Spanned where
184184
return = pure
185-
Spanned x s1 >>= f = let Spanned y s2 = f x in Spanned y (s1 <> s2)
185+
Spanned x s1 >>= f = let Spanned y s2 = f x in Spanned y (s1 Sem.<> s2)
186186

187187
instance Show a => Show (Spanned a) where
188188
show = show . unspan

src/Language/Rust/Parser/Internal.y

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ To get information about transition states and such, run
2626
{-# OPTIONS_HADDOCK hide, not-home #-}
2727
{-# LANGUAGE OverloadedStrings #-}
2828
{-# LANGUAGE OverloadedLists #-}
29-
{-# LANGUAGE PartialTypeSignatures #-}
3029

3130
module Language.Rust.Parser.Internal (
3231
-- * Parsers
@@ -368,33 +367,33 @@ pipe :: { () }
368367
-------------
369368

370369
-- | One or more occurences of 'p'
371-
some(p) :: { Reversed NonEmpty _ }
370+
some(p) :: { Reversed NonEmpty p }
372371
: some(p) p { let Reversed xs = $1 in Reversed ($2 <| xs) }
373372
| p { [$1] }
374373

375374
-- | Zero or more occurences of 'p'
376-
many(p) :: { [ _ ] }
375+
many(p) :: { [ p ] }
377376
: some(p) { toList $1 }
378377
| {- empty -} { [] }
379378

380379
-- | One or more occurences of 'p', seperated by 'sep'
381-
sep_by1(p,sep) :: { Reversed NonEmpty _ }
380+
sep_by1(p,sep) :: { Reversed NonEmpty p }
382381
: sep_by1(p,sep) sep p { let Reversed xs = $1 in Reversed ($3 <| xs) }
383382
| p { [$1] }
384383

385384
-- | Zero or more occurrences of 'p', separated by 'sep'
386-
sep_by(p,sep) :: { [ _ ] }
385+
sep_by(p,sep) :: { [ p ] }
387386
: sep_by1(p,sep) { toList $1 }
388387
| {- empty -} { [] }
389388

390389
-- | One or more occurrences of 'p', seperated by 'sep', optionally ending in 'sep'
391-
sep_by1T(p,sep) :: { Reversed NonEmpty _ }
390+
sep_by1T(p,sep) :: { Reversed NonEmpty p }
392391
: sep_by1(p,sep) sep { $1 }
393392
| sep_by1(p,sep) { $1 }
394393

395394
-- | Zero or more occurences of 'p', seperated by 'sep', optionally ending in 'sep' (only if there
396395
-- is at least one 'p')
397-
sep_byT(p,sep) :: { [ _ ] }
396+
sep_byT(p,sep) :: { [ p ] }
398397
: sep_by1T(p,sep) { toList $1 }
399398
| {- empty -} { [] }
400399

src/Language/Rust/Parser/ParseMonad.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import Language.Rust.Data.InputStream ( InputStream )
4949
import Language.Rust.Data.Position ( Spanned, Position, initPos, prettyPosition )
5050
import Language.Rust.Syntax.Token ( Token )
5151

52+
import Control.Monad.Fail as Fail
5253
import Control.Exception ( Exception )
5354
import Data.Maybe ( listToMaybe )
5455
import Data.Typeable ( Typeable )
@@ -87,9 +88,9 @@ instance Monad P where
8788
let pOk' x s' = unParser (k x) s' pOk pFailed
8889
in unParser m s pOk' pFailed
8990

91+
instance Fail.MonadFail P where
9092
fail msg = P $ \ !s _ pFailed -> pFailed msg (curPos s)
9193

92-
9394
-- | Exceptions that occur during parsing
9495
data ParseFail = ParseFail Position String deriving (Eq, Typeable)
9596

@@ -165,5 +166,5 @@ popToken = P $ \ !s@PState{ pushedTokens = toks } pOk _ -> pOk (listToMaybe toks
165166

166167
-- | Signal a syntax error.
167168
parseError :: Show b => b -> P a
168-
parseError b = fail ("Syntax error: the symbol `" ++ show b ++ "' does not fit here")
169+
parseError b = Fail.fail ("Syntax error: the symbol `" ++ show b ++ "' does not fit here")
169170

src/Language/Rust/Parser/Reversed.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module Language.Rust.Parser.Reversed (
2727
import Language.Rust.Data.Position
2828

2929
import Data.Foldable ( Foldable(toList) )
30-
import Data.Semigroup ( Semigroup(..) )
30+
import Data.Semigroup as Sem ( Semigroup(..) )
3131

3232
import qualified Data.List.NonEmpty as N
3333
import qualified GHC.Exts as G
@@ -46,8 +46,8 @@ instance Foldable (Reversed N.NonEmpty) where
4646
foldMap f (Reversed xs) = foldMap f (N.reverse xs)
4747
toList (Reversed xs) = reverse (toList xs)
4848

49-
instance Semigroup (f a) => Semigroup (Reversed f a) where
50-
Reversed xs <> Reversed ys = Reversed (ys <> xs)
49+
instance Sem.Semigroup (f a) => Sem.Semigroup (Reversed f a) where
50+
Reversed xs <> Reversed ys = Reversed (ys Sem.<> xs)
5151

5252
instance Monoid (f a) => Monoid (Reversed f a) where
5353
mempty = Reversed mempty

src/Language/Rust/Pretty/Util.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ neutral element for @<+>@, @hsep@, @<#>@, @vsep@, and @</>@.
2323

2424
module Language.Rust.Pretty.Util where
2525

26-
import Data.Monoid ( (<>) )
26+
import Data.Monoid as M
2727

2828
import qualified Data.Text.Prettyprint.Doc as PP
2929
import Data.Text.Prettyprint.Doc.Internal.Type ( Doc(..) )
@@ -44,11 +44,11 @@ emptyElim _ f doc = f doc
4444

4545
-- | Vertically concatenate two 'Doc's with a collapsible line between them
4646
(<##>) :: Doc a -> Doc a -> Doc a
47-
d1 <##> d2 = d1 <> PP.line' <> d2
47+
d1 <##> d2 = d1 M.<> PP.line' M.<> d2
4848

4949
-- | Flatten a 'Doc'
5050
flatten :: Doc a -> Doc a
51-
flatten d@Fail{} = d
51+
flatten d@Fail{} = d
5252
flatten d@Empty{} = d
5353
flatten d@Char{} = d
5454
flatten d@Text{} = d

0 commit comments

Comments
 (0)