Skip to content

Commit

Permalink
Restore compatibility with GHC 7.4 (#187)
Browse files Browse the repository at this point in the history
Context: #186
  • Loading branch information
sjakobi committed Jul 25, 2020
1 parent 01e0c79 commit 4fa6857
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
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

0 comments on commit 4fa6857

Please sign in to comment.