Skip to content

Commit 65e85c5

Browse files
authored
Merge pull request #175 from inariksit/new-ghc
Changes to make it work with newer stack/GHC: - unix library changed API in 2.8 - Monad of no return & Semigroup as a superclass of Monoid - import Control.Monad (join, when, (<=<)) - fixed CI issues
2 parents 981d6b9 + 01c4f82 commit 65e85c5

File tree

20 files changed

+86
-59
lines changed

20 files changed

+86
-59
lines changed

.github/workflows/build-all-versions.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,34 @@ jobs:
1212
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
1313
runs-on: ${{ matrix.os }}
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
os: [ubuntu-latest, macos-latest, windows-latest]
1718
cabal: ["latest"]
1819
ghc:
1920
- "8.6.5"
2021
- "8.8.3"
2122
- "8.10.7"
23+
- "9.6.6"
2224
exclude:
2325
- os: macos-latest
2426
ghc: 8.8.3
2527
- os: macos-latest
2628
ghc: 8.6.5
29+
- os: macos-latest
30+
ghc: 8.10.7
2731
- os: windows-latest
2832
ghc: 8.8.3
2933
- os: windows-latest
3034
ghc: 8.6.5
35+
- os: windows-latest
36+
ghc: 8.10.7
3137

3238
steps:
3339
- uses: actions/checkout@v2
3440
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
3541

36-
- uses: haskell/actions/setup@v2
42+
- uses: haskell-actions/setup@v2
3743
id: setup-haskell-cabal
3844
name: Setup Haskell
3945
with:
@@ -44,7 +50,7 @@ jobs:
4450
run: |
4551
cabal freeze
4652
47-
- uses: actions/cache@v1
53+
- uses: actions/cache@v4
4854
name: Cache ~/.cabal/store
4955
with:
5056
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
@@ -66,14 +72,13 @@ jobs:
6672
strategy:
6773
matrix:
6874
stack: ["latest"]
69-
ghc: ["7.10.3","8.0.2", "8.2.2", "8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2"]
70-
# ghc: ["8.8.3"]
75+
ghc: ["8.4.4", "8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.6.6"]
7176

7277
steps:
7378
- uses: actions/checkout@v2
7479
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master'
7580

76-
- uses: haskell/actions/setup@v2
81+
- uses: haskell-actions/setup@v2
7782
name: Setup Haskell Stack
7883
with:
7984
ghc-version: ${{ matrix.ghc }}
@@ -85,7 +90,7 @@ jobs:
8590
- run: sed -i.bak 's/"C compiler link flags", "/&-no-pie /' /home/runner/.ghcup/ghc/7.10.3/lib/ghc-7.10.3/settings
8691
if: matrix.ghc == '7.10.3'
8792

88-
- uses: actions/cache@v1
93+
- uses: actions/cache@v4
8994
name: Cache ~/.stack
9095
with:
9196
path: ~/.stack

gf.cabal

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ library
7373
build-depends:
7474
-- GHC 8.0.2 to GHC 8.10.4
7575
array >= 0.5.1 && < 0.6,
76-
base >= 4.9.1 && < 4.17,
76+
base >= 4.9.1 && < 4.22,
7777
bytestring >= 0.10.8 && < 0.12,
7878
containers >= 0.5.7 && < 0.7,
7979
exceptions >= 0.8.3 && < 0.11,
80-
ghc-prim >= 0.5.0 && < 0.9.0,
81-
mtl >= 2.2.1 && < 2.3,
80+
ghc-prim >= 0.5.0 && <= 0.10.0,
81+
mtl >= 2.2.1 && <= 2.3.1,
8282
pretty >= 1.1.3 && < 1.2,
8383
random >= 1.1 && < 1.3,
8484
utf8-string >= 1.0.1.1 && < 1.1
@@ -155,10 +155,10 @@ library
155155
directory >= 1.3.0 && < 1.4,
156156
filepath >= 1.4.1 && < 1.5,
157157
haskeline >= 0.7.3 && < 0.9,
158-
json >= 0.9.1 && < 0.11,
158+
json >= 0.9.1 && <= 0.11,
159159
parallel >= 3.2.1.1 && < 3.3,
160160
process >= 1.4.3 && < 1.7,
161-
time >= 1.6.0 && < 1.10
161+
time >= 1.6.0 && <= 1.12.2
162162

163163
hs-source-dirs: src/compiler
164164
exposed-modules:
@@ -346,8 +346,14 @@ library
346346
Win32 >= 2.3.1.1 && < 2.7
347347
else
348348
build-depends:
349-
terminfo >=0.4.0 && < 0.5,
350-
unix >= 2.7.2 && < 2.8
349+
terminfo >=0.4.0 && < 0.5
350+
351+
if impl(ghc >= 9.6.6)
352+
build-depends: unix >= 2.8
353+
354+
else
355+
build-depends: unix >= 2.7.2 && < 2.8
356+
351357

352358
if impl(ghc>=8.2)
353359
ghc-options: -fhide-source-paths
@@ -392,7 +398,7 @@ test-suite gf-tests
392398
main-is: run.hs
393399
hs-source-dirs: testsuite
394400
build-depends:
395-
base >= 4.9.1 && < 4.16,
401+
base >= 4.9.1,
396402
Cabal >= 1.8,
397403
directory >= 1.3.0 && < 1.4,
398404
filepath >= 1.4.1 && < 1.5,

src/compiler/GF/Compile/Compute/Concrete.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ value env t0 =
172172
ImplArg t -> (VImplArg.) # value env t
173173
Table p res -> liftM2 VTblType # value env p <# value env res
174174
RecType rs -> do lovs <- mapPairsM (value env) rs
175-
return $ \vs->VRecType $ mapSnd ($vs) lovs
175+
return $ \vs->VRecType $ mapSnd ($ vs) lovs
176176
t@(ExtR t1 t2) -> ((extR t.)# both id) # both (value env) (t1,t2)
177177
FV ts -> ((vfv .) # sequence) # mapM (value env) ts
178178
R as -> do lovs <- mapPairsM (value env.snd) as
179-
return $ \ vs->VRec $ mapSnd ($vs) lovs
179+
return $ \ vs->VRec $ mapSnd ($ vs) lovs
180180
T i cs -> valueTable env i cs
181181
V ty ts -> do pvs <- paramValues env ty
182182
((VV ty pvs .) . sequence) # mapM (value env) ts
@@ -376,10 +376,10 @@ valueTable env i cs =
376376
where
377377
dynamic cs' ty _ = cases cs' # value env ty
378378

379-
cases cs' vty vs = err keep ($vs) (convertv cs' (vty vs))
379+
cases cs' vty vs = err keep ($ vs) (convertv cs' (vty vs))
380380
where
381381
keep msg = --trace (msg++"\n"++render (ppTerm Unqualified 0 (T i cs))) $
382-
VT wild (vty vs) (mapSnd ($vs) cs')
382+
VT wild (vty vs) (mapSnd ($ vs) cs')
383383

384384
wild = case i of TWild _ -> True; _ -> False
385385

@@ -392,7 +392,7 @@ valueTable env i cs =
392392
convert' cs' ((pty,vs),pvs) =
393393
do sts <- mapM (matchPattern cs') vs
394394
return $ \ vs -> VV pty pvs $ map (err bug id . valueMatch env)
395-
(mapFst ($vs) sts)
395+
(mapFst ($ vs) sts)
396396

397397
valueCase (p,t) = do p' <- measurePatt # inlinePattMacro p
398398
pvs <- linPattVars p'
@@ -430,19 +430,19 @@ apply' :: CompleteEnv -> Term -> [OpenValue] -> Err OpenValue
430430
apply' env t [] = value env t
431431
apply' env t vs =
432432
case t of
433-
QC x -> return $ \ svs -> VCApp x (map ($svs) vs)
433+
QC x -> return $ \ svs -> VCApp x (map ($ svs) vs)
434434
{-
435435
Q x@(m,f) | m==cPredef -> return $
436436
let constr = --trace ("predef "++show x) .
437437
VApp x
438438
in \ svs -> maybe constr id (Map.lookup f predefs)
439-
$ map ($svs) vs
439+
$ map ($ svs) vs
440440
| otherwise -> do r <- resource env x
441-
return $ \ svs -> vapply (gloc env) r (map ($svs) vs)
441+
return $ \ svs -> vapply (gloc env) r (map ($ svs) vs)
442442
-}
443443
App t1 t2 -> apply' env t1 . (:vs) =<< value env t2
444444
_ -> do fv <- value env t
445-
return $ \ svs -> vapply (gloc env) (fv svs) (map ($svs) vs)
445+
return $ \ svs -> vapply (gloc env) (fv svs) (map ($ svs) vs)
446446

447447
vapply :: GLocation -> Value -> [Value] -> Value
448448
vapply loc v [] = v

src/compiler/GF/Compile/GeneratePMCFG.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ instance Fail.MonadFail CnvMonad where
201201
fail = bug
202202

203203
instance Applicative CnvMonad where
204-
pure = return
204+
pure a = CM (\gr c s -> c a s)
205205
(<*>) = ap
206206

207207
instance Monad CnvMonad where
208-
return a = CM (\gr c s -> c a s)
208+
return = pure
209209
CM m >>= k = CM (\gr c s -> m gr (\a s -> unCM (k a) gr c s) s)
210210

211211
instance MonadState ([ProtoFCat],[Symbol]) CnvMonad where

src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ data TcResult a
644644
newtype TcM a = TcM {unTcM :: MetaStore -> [Message] -> TcResult a}
645645

646646
instance Monad TcM where
647-
return x = TcM (\ms msgs -> TcOk x ms msgs)
647+
return = pure
648648
f >>= g = TcM (\ms msgs -> case unTcM f ms msgs of
649649
TcOk x ms msgs -> unTcM (g x) ms msgs
650650
TcFail msgs -> TcFail msgs)
@@ -659,7 +659,7 @@ instance Fail.MonadFail TcM where
659659

660660

661661
instance Applicative TcM where
662-
pure = return
662+
pure x = TcM (\ms msgs -> TcOk x ms msgs)
663663
(<*>) = ap
664664

665665
instance Functor TcM where

src/compiler/GF/CompileInParallel.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ parallelBatchCompile jobs opts rootfiles0 =
6161

6262
usesPresent (_,paths) = take 1 libs==["present"]
6363
where
64-
libs = [p|path<-paths,
65-
let (d,p0) = splitAt n path
66-
p = dropSlash p0,
67-
d==lib_dir,p `elem` all_modes]
68-
n = length lib_dir
64+
libs = [p | path<-paths,
65+
let (d,p0) = splitAt n path
66+
p = dropSlash p0,
67+
d==lib_dir, p `elem` all_modes]
68+
n = length lib_dir
6969

7070
all_modes = ["alltenses","present"]
7171

@@ -175,7 +175,7 @@ batchCompile1 lib_dir (opts,filepaths) =
175175
" from being compiled."
176176
else return (maximum ts,(cnc,gr))
177177

178-
splitEither es = ([x|Left x<-es],[y|Right y<-es])
178+
splitEither es = ([x | Left x<-es], [y | Right y<-es])
179179

180180
canonical path = liftIO $ D.canonicalizePath path `catch` const (return path)
181181

@@ -238,12 +238,12 @@ runCO (CO m) = do (o,x) <- m
238238
instance Functor m => Functor (CollectOutput m) where
239239
fmap f (CO m) = CO (fmap (fmap f) m)
240240

241-
instance (Functor m,Monad m) => Applicative (CollectOutput m) where
242-
pure = return
241+
instance (Functor m,Monad m) => Applicative (CollectOutput m) where
242+
pure x = CO (return (return (),x))
243243
(<*>) = ap
244244

245245
instance Monad m => Monad (CollectOutput m) where
246-
return x = CO (return (return (),x))
246+
return = pure
247247
CO m >>= f = CO $ do (o1,x) <- m
248248
let CO m2 = f x
249249
(o2,y) <- m2

src/compiler/GF/Data/BacktrackM.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ finalStates :: BacktrackM s () -> s -> [s]
6464
finalStates bm = map fst . runBM bm
6565

6666
instance Applicative (BacktrackM s) where
67-
pure = return
67+
pure a = BM (\c s b -> c a s b)
6868
(<*>) = ap
6969

7070
instance Monad (BacktrackM s) where
71-
return a = BM (\c s b -> c a s b)
71+
return = pure
7272
BM m >>= k = BM (\c s b -> m (\a s b -> unBM (k a) c s b) s b)
7373
where unBM (BM m) = m
7474

src/compiler/GF/Data/ErrM.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fromErr :: a -> Err a -> a
3434
fromErr a = err (const a) id
3535

3636
instance Monad Err where
37-
return = Ok
37+
return = pure
3838
Ok a >>= f = f a
3939
Bad s >>= f = Bad s
4040

@@ -54,7 +54,7 @@ instance Functor Err where
5454
fmap f (Bad s) = Bad s
5555

5656
instance Applicative Err where
57-
pure = return
57+
pure = Ok
5858
(<*>) = ap
5959

6060
-- | added by KJ

src/compiler/GF/Grammar/Lexer.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ instance Functor P where
283283
fmap = liftA
284284
285285
instance Applicative P where
286-
pure = return
286+
pure a = a `seq` (P $ \s -> POk s a)
287287
(<*>) = ap
288288
289289
instance Monad P where
290-
return a = a `seq` (P $ \s -> POk s a)
290+
return = pure
291291
(P m) >>= k = P $ \ s -> case m s of
292292
POk s a -> unP (k a) s
293293
PFailed posn err -> PFailed posn err

src/compiler/GF/Infra/CheckM.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ newtype Check a
4848
instance Functor Check where fmap = liftM
4949

5050
instance Monad Check where
51-
return x = Check $ \{-ctxt-} ws -> (ws,Success x)
51+
return = pure
5252
f >>= g = Check $ \{-ctxt-} ws ->
5353
case unCheck f {-ctxt-} ws of
5454
(ws,Success x) -> unCheck (g x) {-ctxt-} ws
@@ -58,7 +58,7 @@ instance Fail.MonadFail Check where
5858
fail = raise
5959

6060
instance Applicative Check where
61-
pure = return
61+
pure x = Check $ \{-ctxt-} ws -> (ws,Success x)
6262
(<*>) = ap
6363

6464
instance ErrorMonad Check where

0 commit comments

Comments
 (0)