Skip to content

Commit 4fa6857

Browse files
authored
Restore compatibility with GHC 7.4 (#187)
Context: #186
1 parent 01e0c79 commit 4fa6857

File tree

2 files changed

+9
-17
lines changed
  • prettyprinter-ansi-terminal/src/Prettyprinter/Render/Terminal
  • prettyprinter/src/Prettyprinter/Render

2 files changed

+9
-17
lines changed

prettyprinter-ansi-terminal/src/Prettyprinter/Render/Terminal/Internal.hs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE CPP #-}
2-
{-# LANGUAGE LambdaCase #-}
32
{-# LANGUAGE OverloadedStrings #-}
43

54
{-# OPTIONS_HADDOCK not-home #-}
@@ -63,12 +62,6 @@ modifyIORef' ref f = do
6362
x <- readIORef ref
6463
let x' = f x
6564
x' `seq` writeIORef ref x'
66-
67-
modifySTRef' :: STRef s a -> (a -> a) -> ST s ()
68-
modifySTRef' ref f = do
69-
x <- readSTRef ref
70-
let x' = f x
71-
x' `seq` writeSTRef ref x'
7265
#endif
7366

7467
-- $setup
@@ -150,15 +143,15 @@ underlined = mempty { ansiUnderlining = Just Underlined }
150143
renderLazy :: SimpleDocStream AnsiStyle -> TL.Text
151144
renderLazy =
152145
let push x = (x :)
153-
unsafePeek = \case
154-
[] -> panicPeekedEmpty
155-
x:_ -> x
156-
unsafePop = \case
157-
[] -> panicPeekedEmpty
158-
x:xs -> (x, xs)
146+
147+
unsafePeek [] = panicPeekedEmpty
148+
unsafePeek (x:_) = x
149+
150+
unsafePop [] = panicPoppedEmpty
151+
unsafePop (x:xs) = (x, xs)
159152

160153
go :: [AnsiStyle] -> SimpleDocStream AnsiStyle -> TLB.Builder
161-
go s = \case
154+
go s sds = case sds of
162155
SFail -> panicUncaughtFail
163156
SEmpty -> mempty
164157
SChar c rest -> TLB.singleton c <> go s rest
@@ -205,7 +198,7 @@ renderIO h sdoc = do
205198
[] -> panicPeekedEmpty
206199
x:_ -> pure x
207200
unsafePop = readIORef styleStackRef >>= \tok -> case tok of
208-
[] -> panicPeekedEmpty
201+
[] -> panicPoppedEmpty
209202
x:xs -> writeIORef styleStackRef xs >> pure x
210203

211204
let go = \sds -> case sds of

prettyprinter/src/Prettyprinter/Render/Text.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE CPP #-}
2-
{-# LANGUAGE LambdaCase #-}
32
{-# LANGUAGE OverloadedStrings #-}
43

54
#include "version-compatibility-macros.h"
@@ -58,7 +57,7 @@ import Control.Applicative
5857
renderLazy :: SimpleDocStream ann -> TL.Text
5958
renderLazy = TLB.toLazyText . go
6059
where
61-
go = \case
60+
go x = case x of
6261
SFail -> panicUncaughtFail
6362
SEmpty -> mempty
6463
SChar c rest -> TLB.singleton c <> go rest

0 commit comments

Comments
 (0)