Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore compatibility with GHC 7.4 #187

Merged
merged 1 commit into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}

{-# OPTIONS_HADDOCK not-home #-}
Expand Down Expand Up @@ -63,12 +62,6 @@ modifyIORef' ref f = do
x <- readIORef ref
let x' = f x
x' `seq` writeIORef ref x'

modifySTRef' :: STRef s a -> (a -> a) -> ST s ()
modifySTRef' ref f = do
x <- readSTRef ref
let x' = f x
x' `seq` writeSTRef ref x'
#endif

-- $setup
Expand Down Expand Up @@ -150,15 +143,15 @@ underlined = mempty { ansiUnderlining = Just Underlined }
renderLazy :: SimpleDocStream AnsiStyle -> TL.Text
renderLazy =
let push x = (x :)
unsafePeek = \case
[] -> panicPeekedEmpty
x:_ -> x
unsafePop = \case
[] -> panicPeekedEmpty
x:xs -> (x, xs)

unsafePeek [] = panicPeekedEmpty
unsafePeek (x:_) = x

unsafePop [] = panicPoppedEmpty
unsafePop (x:xs) = (x, xs)

go :: [AnsiStyle] -> SimpleDocStream AnsiStyle -> TLB.Builder
go s = \case
go s sds = case sds of
SFail -> panicUncaughtFail
SEmpty -> mempty
SChar c rest -> TLB.singleton c <> go s rest
Expand Down Expand Up @@ -205,7 +198,7 @@ renderIO h sdoc = do
[] -> panicPeekedEmpty
x:_ -> pure x
unsafePop = readIORef styleStackRef >>= \tok -> case tok of
[] -> panicPeekedEmpty
[] -> panicPoppedEmpty
x:xs -> writeIORef styleStackRef xs >> pure x

let go = \sds -> case sds of
Expand Down
3 changes: 1 addition & 2 deletions prettyprinter/src/Prettyprinter/Render/Text.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}

#include "version-compatibility-macros.h"
Expand Down Expand Up @@ -58,7 +57,7 @@ import Control.Applicative
renderLazy :: SimpleDocStream ann -> TL.Text
renderLazy = TLB.toLazyText . go
where
go = \case
go x = case x of
SFail -> panicUncaughtFail
SEmpty -> mempty
SChar c rest -> TLB.singleton c <> go rest
Expand Down