Skip to content

Commit

Permalink
Add support for GHC 9.10
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
martijnbastiaan committed Apr 15, 2024
1 parent d73df0a commit 55372da
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 20 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ jobs:
- os: windows-latest
ghc: 8.8.4

# # Uncomment if testing with an unreleased GHC. Make sure to edit the
# # "Setup Haskell (head)" step too.
# include:
# - os: ubuntu-22.04
# ghc: head
# Uncomment if testing with an unreleased GHC. Make sure to edit the
# "Setup Haskell (head)" step too.
include:
- os: ubuntu-22.04
ghc: head
fail-fast: false
steps:
- name: Checkout
Expand All @@ -93,8 +93,9 @@ jobs:
sudo apt-get update
sudo apt-get install -y build-essential curl libffi-dev libffi8ubuntu1 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
ghcup install -u https://downloads.haskell.org/ghc/9.6.1/ghc-9.6.1-x86_64-deb9-linux.tar.xz ghc-head
ghcup set ghc ghc-head
ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml
ghcup install ghc 9.10.0.20240328
ghcup set ghc 9.10.0.20240328
echo "cabal-store=$HOME/.cabal/store" >> $GITHUB_OUTPUT
- name: Setup CI
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.3.1.1
* Add support for GHC 9.10

# 0.3.1
* Add support for GHC 9.8
* Drop support for GHC 8.2
Expand Down
9 changes: 7 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ packages:

write-ghc-environment-files: always

tests: true

source-repository-package
type: git
location: https://github.com/haskell-unordered-containers/unordered-containers.git
tag: d52a0fd10bfa701cbbc9d7ac06bd7eb7664b3972

allow-newer:
*:base
, *:ghc-bignum
unordered-containers:template-haskell
5 changes: 3 additions & 2 deletions doctest-parallel.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.0

name: doctest-parallel
version: 0.3.1
version: 0.3.1.1
synopsis: Test interactive Haskell examples
description: The doctest program checks examples in source code comments. It is modeled
after doctest for Python (<https://docs.python.org/3/library/doctest.html>).
Expand All @@ -26,6 +26,7 @@ tested-with:
, GHC == 9.4.7
, GHC == 9.6.3
, GHC == 9.8.1
, GHC == 9.10.1

extra-source-files:
example/example.cabal
Expand Down Expand Up @@ -102,7 +103,7 @@ library
, directory
, exceptions
, filepath
, ghc >=8.2 && <9.9
, ghc >=8.2 && <9.11
, ghc-paths >=0.1.0.9
, process
, random >= 1.2
Expand Down
4 changes: 3 additions & 1 deletion src/Test/DocTest/Internal/Extract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,10 @@ extractLit loc = \case
#else
#if __GLASGOW_HASKELL__ < 904
HsPar _ (L l e) -> extractLit (locA l) e
#else
#elif __GLASGOW_HASKELL__ < 909
HsPar _ _ (L l e) _ -> extractLit (locA l) e
#else
HsPar _ (L l e) -> extractLit (locA l) e
#endif
#if __GLASGOW_HASKELL__ < 807
ExprWithTySig _ (L l e) -> extractLit l e
Expand Down
37 changes: 31 additions & 6 deletions src/Test/DocTest/Internal/Interpreter.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{-# LANGUAGE CPP #-}

#if __GLASGOW_HASKELL__ <= 906
{-# LANGUAGE LambdaCase #-}
#endif

module Test.DocTest.Internal.Interpreter (
Interpreter
, safeEval
Expand All @@ -18,6 +22,9 @@ import System.Directory (getPermissions, executable)
import Control.Monad
import Control.Exception hiding (handle)
import Data.Char
#if __GLASGOW_HASKELL__ > 906
import Data.List (unsnoc)
#endif
import GHC.Paths (ghc)

import Test.DocTest.Internal.GhciWrapper
Expand All @@ -27,6 +34,24 @@ import Test.DocTest.Internal.Logging (DebugLogger)
-- >>> import Test.DocTest.Internal.GhciWrapper (eval)
-- >>> import Test.DocTest.Internal.Logging (noLogger)

#if __GLASGOW_HASKELL__ <= 906
-- | If the list is empty returns 'Nothing', otherwise returns the 'init' and the 'last'.
--
-- > unsnoc "test" == Just ("tes",'t')
-- > unsnoc "" == Nothing
-- > \xs -> unsnoc xs == if null xs then Nothing else Just (init xs, last xs)
unsnoc :: [a] -> Maybe ([a], a)
unsnoc :: [a] -> Maybe ([a], a)

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 8.6.5

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 9.0.2

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 9.2.8

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 8.4.4

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 8.10.7

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 8.8.4

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 9.4.7

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Cabal / GHC 9.6.3

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / Cabal / GHC 8.8.4

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / Cabal / GHC 8.10.7

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 / Stack / lts-20.17

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / Cabal / GHC 8.4.4

Duplicate type signatures for ‘unsnoc’

Check failure on line 44 in src/Test/DocTest/Internal/Interpreter.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / Cabal / GHC 8.6.5

Duplicate type signatures for ‘unsnoc’
unsnoc = \case
[] -> Nothing
x:xs -> Just $ unsnoc1 x xs
where
unsnoc1 :: a -> [a] -> ([a], a)
unsnoc1 x = \case
[] -> ([], x)
y:ys -> first (x:) $ unsnoc1 y ys
#endif

haveInterpreterKey :: String
haveInterpreterKey = "Have interpreter"

Expand Down Expand Up @@ -76,13 +101,13 @@ safeEvalIt repl = either (return . Left) (fmap Right . evalIt repl) . filterExpr

filterExpression :: String -> Either String String
filterExpression e =
case lines e of
case map strip (lines e) of
[] -> Right e
l -> if firstLine == ":{" && lastLine /= ":}" then fail_ else Right e
where
firstLine = strip $ head l
lastLine = strip $ last l
fail_ = Left "unterminated multiline command"
(firstLine:ls) ->
let lastLine = maybe firstLine snd (unsnoc ls) in
if firstLine == ":{" && lastLine /= ":}" then fail_ else Right e
where
fail_ = Left "unterminated multiline command"

strip :: String -> String
strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse
2 changes: 1 addition & 1 deletion src/Test/DocTest/Internal/Runner/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mkResult expected_ actual_ =
-- use show to escape special characters in output lines if any output line
-- contains any unsafe character
escapeOutput
| any (not . isSafe) $ concat (expectedAsString ++ actual_) = init . tail . show . stripEnd
| any (not . isSafe) $ concat (expectedAsString ++ actual_) = init . drop 1 . show . stripEnd
| otherwise = id

actual :: [String]
Expand Down
2 changes: 1 addition & 1 deletion test/PropertySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec = do
runProperty repl "x == 23" `shouldReturn` Failure "*** Failed! Falsified (after 1 test):\n0"

it "reports the values for which a property that takes multiple arguments fails" $ withInterpreter noLogger [] $ \repl -> do
let vals x = case x of (Failure r) -> tail (lines r); _ -> error "Property did not fail!"
let vals x = case x of (Failure r) -> drop 1 (lines r); _ -> error "Property did not fail!"
vals `fmap` runProperty repl "x == True && y == 10 && z == \"foo\"" `shouldReturn` ["False", "0", show ("" :: String)]

it "defaults ambiguous type variables to Integer" $ withInterpreter noLogger [] $ \repl -> do
Expand Down

0 comments on commit 55372da

Please sign in to comment.