Skip to content

Commit 72623e1

Browse files
committed
Update conditional code (#if)
* Remove conditional code obsolete with GHC >= 8 * Fix import warning for foldl'
1 parent cf37896 commit 72623e1

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/Network/NetRc.hs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ import qualified Data.ByteString.Char8 as BC
5555
import qualified Data.ByteString.Lazy as LB
5656
import Data.Data
5757
import Data.Either (rights, lefts)
58-
import Data.List (intersperse, foldl')
59-
import Data.Monoid
58+
import Data.List (intersperse)
59+
#if !MIN_VERSION_base(4,20,0)
60+
import Data.List (foldl')
61+
#endif
62+
#if !MIN_VERSION_base(4,11,0)
63+
import Data.Semigroup ((<>))
64+
#endif
6065
import GHC.Generics
6166
import System.Environment
6267
import System.IO.Error
@@ -142,12 +147,7 @@ netRcToBuilder (NetRc ms ds) =
142147
--
143148
-- This is currently just a convenience wrapper around 'netRcToBuilder'
144149
netRcToByteString :: NetRc -> ByteString
145-
#if MIN_VERSION_bytestring(0,10,0)
146150
netRcToByteString = LB.toStrict . BB.toLazyByteString . netRcToBuilder
147-
#else
148-
netRcToByteString = B.concat . LB.toChunks . BB.toLazyByteString . netRcToBuilder
149-
#endif
150-
151151

152152
-- | Convenience wrapper for 'netRcParsec' parser
153153
--
@@ -163,7 +163,6 @@ netRcToByteString = B.concat . LB.toChunks . BB.toLazyByteString . netRcToBuilde
163163
parseNetRc :: P.SourceName -> ByteString -> Either P.ParseError NetRc
164164
parseNetRc = P.parse (netRcParsec <* P.eof)
165165

166-
167166
-- | Reads and parses default @$HOME/.netrc@
168167
--
169168
-- Returns 'Nothing' if @$HOME@ variable undefined and/or if @.netrc@ if missing.
@@ -184,10 +183,6 @@ readUserNetRc = do
184183
Left e | isDoesNotExistError e -> return Nothing
185184
| otherwise -> ioError e
186185
Right b -> return $! Just $! parseNetRc fn b
187-
#if !(MIN_VERSION_base(4,6,0))
188-
where
189-
lookupEnv k = lookup k <$> getEnvironment
190-
#endif
191186

192187
-- | "Text.Parsec.ByteString" 'P.Parser' for @.netrc@ grammar
193188
netRcParsec :: P.Parser NetRc

0 commit comments

Comments
 (0)