Skip to content

Commit 6a9b239

Browse files
committed
Use -v0
1 parent 0231c87 commit 6a9b239

File tree

5 files changed

+39
-20
lines changed

5 files changed

+39
-20
lines changed

cabal-docspec/MANUAL.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,15 +515,14 @@ All warnings are enabled by default.
515515
KNOWN BUGS AND INFECILITIES
516516
===========================
517517

518-
Multiline input is not well supported with GHC prior to 7.8, as these lack way to suppress secondary prompt output.
519-
https://gitlab.haskell.org/ghc/ghc/-/issues/7509
520-
521518
Properties (**prop>**) are recognized but not evaluated.
522519

523520
Literate Haskell is not supported.
524521

525522
Failures in the setup code does not cause module skip.
526523

524+
GHC-7.0 relies that *Char* type is in scope. This is an implementation artifact.
525+
527526
SEE ALSO
528527
========
529528

cabal-docspec/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=0.0.0.20201229
1+
VERSION=0.0.0.20201230
22

33
cabal-docspec.1 : MANUAL.md
44
echo '.TH CABAL-DOCSPEC 1 "December 26, 2020" "cabal-docspec $(VERSION)" "Cabal Extras"' > cabal-docspec.1

cabal-docspec/cabal-docspec.1

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH CABAL-DOCSPEC 1 "December 26, 2020" "cabal-docspec 0.0.0.20201229" "Cabal Extras"
1+
.TH CABAL-DOCSPEC 1 "December 26, 2020" "cabal-docspec 0.0.0.20201230" "Cabal Extras"
22
.SH NAME
33
.PP
44
cabal-docspec - another doctest for Haskell
@@ -567,15 +567,14 @@ Warn when parsing of cabal package file fields fails.
567567
C preprocessor (\f[I]cpphs\f[R]) warnings.
568568
.SH KNOWN BUGS AND INFECILITIES
569569
.PP
570-
Multiline input is not well supported with GHC prior to 7.8, as these
571-
lack way to suppress secondary prompt output.
572-
https://gitlab.haskell.org/ghc/ghc/-/issues/7509
573-
.PP
574570
Properties (\f[B]prop>\f[R]) are recognized but not evaluated.
575571
.PP
576572
Literate Haskell is not supported.
577573
.PP
578574
Failures in the setup code does not cause module skip.
575+
.PP
576+
GHC-7.0 relies that \f[I]Char\f[R] type is in scope.
577+
This is an implementation artifact.
579578
.SH SEE ALSO
580579
.PP
581580
doctest(1) https://hackage.haskell.org/package/doctest

cabal-docspec/cabal-docspec.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: cabal-docspec
3-
version: 0.0.0.20201229
3+
version: 0.0.0.20201230
44
synopsis: Run examples in your docs
55
category: Development
66
description:

cabal-docspec/src/CabalDocspec/GHCi.hs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import CabalDocspec.Trace
2020
import CabalDocspec.Warning
2121

2222
-- | Handle to GHCi process.
23-
newtype GHCi = GHCi Proci.IPH
23+
data GHCi = GHCi !Proci.IPH !MarkerType
24+
25+
data MarkerType
26+
= MT_DSS -- ^ @Data.String.String@
27+
| MT_Char -- ^ @[Char]@
28+
-- | MT_None -- this an option too, not configurable atm.
2429

2530
-- | Run interactive GHCi
2631
withInteractiveGhc
@@ -34,7 +39,14 @@ withInteractiveGhc tracer ghcInfo cwd args kont = do
3439
traceApp tracer $ TraceGHCi (ghcPath ghcInfo) args'
3540

3641
Proci.withInteractiveProcess pc1 $ \iph -> do
37-
let ghci = GHCi iph
42+
let mt :: MarkerType
43+
mt | ghcVersion ghcInfo >= mkVersion [7,2]
44+
= MT_DSS
45+
46+
| otherwise
47+
= MT_Char
48+
49+
let ghci = GHCi iph mt
3850
setupGhci tracer ghcInfo ghci
3951
kont ghci
4052
where
@@ -43,15 +55,19 @@ withInteractiveGhc tracer ghcInfo cwd args kont = do
4355
{ Proc.cwd = Just (toFilePath cwd)
4456
}
4557

46-
args' = ["--interactive", "-ignore-dot-ghci"] ++ args
58+
args' = ["--interactive", "-ignore-dot-ghci", "-v0"] ++ args
4759

4860
setupGhci :: TracerPeu r Tr -> GhcInfo -> GHCi -> Peu r ()
49-
setupGhci tracer _ghcInfo ghci@(GHCi iph) = do
61+
setupGhci tracer _ghcInfo ghci@(GHCi iph _mt) = do
5062
-- turn off prompt
5163
-- it is fine to send these, even if they may not work.
52-
Proci.sendTo iph ":set prompt \"\"\n"
53-
Proci.sendTo iph ":set prompt2 \"\"\n" -- GHC-7.8+
54-
Proci.sendTo iph ":set prompt-cont \"\"\n" -- GHC-8.2+
64+
65+
-- Proci.sendTo iph ":set prompt \"\"\n"
66+
-- Proci.sendTo iph ":set prompt2 \"\"\n" -- GHC-7.8+
67+
-- Proci.sendTo iph ":set prompt-cont \"\"\n" -- GHC-8.2+
68+
69+
-- We don't actually need these, as -v0 argument suppresses prompt echo when terminal is not tty!
70+
-- https://gitlab.haskell.org/ghc/ghc/-/blob/cbc7c3dda6bdf4acb760ca9eb545faeb98ab0dbe/ghc/GHCi/UI.hs#L688-691
5571

5672
-- wait a little. I'm not sure if we need this delay
5773
liftIO $ threadDelay 10000
@@ -80,10 +96,15 @@ data Result
8096
| Timeout
8197

8298
waitGhci :: TracerPeu r Tr -> GHCi -> Maybe String -> Int -> Peu r Result
83-
waitGhci _tracer (GHCi iph) mitVar microsecs = do
99+
waitGhci _tracer (GHCi iph mt) mitVar microsecs = do
100+
let mt' :: String
101+
mt' = case mt of
102+
MT_DSS -> "Data.String.String" -- works for most
103+
MT_Char -> "[Char]" -- works for GHC-7.0
104+
84105
-- send separator
85106
separator <- show <$> genString
86-
Proci.sendTo iph $ fromString $ separator ++ " :: Data.String.String\n"
107+
Proci.sendTo iph $ fromString $ separator ++ " :: " ++ mt' ++ "\n"
87108

88109
for_ mitVar $ \itVar -> do
89110
Proci.sendTo iph $ fromString $ "let it = " ++ itVar ++ "\n"
@@ -120,7 +141,7 @@ waitGhci _tracer (GHCi iph) mitVar microsecs = do
120141
-- | Send expressions (individual lines)
121142
-- wait for combined response.
122143
sendExpressions :: TracerPeu r Tr -> GHCi -> Bool -> Int -> [String] -> Peu r Result
123-
sendExpressions tracer ghci@(GHCi iph) preserveIt timeout exprs = do
144+
sendExpressions tracer ghci@(GHCi iph _mt) preserveIt timeout exprs = do
124145
-- send expressions
125146
for_ exprs $ \expr -> do
126147
Proci.sendTo iph (toUTF8BS expr <> "\n")

0 commit comments

Comments
 (0)