1
1
{-# LANGUAGE LambdaCase #-}
2
+ {-# LANGUAGE CPP #-}
2
3
{-# LANGUAGE OverloadedStrings #-}
3
4
{-# LANGUAGE NoMonomorphismRestriction #-}
4
5
{-# LANGUAGE FlexibleContexts #-}
@@ -12,6 +13,7 @@ module NixFromNpm.Common (
12
13
module Control.Applicative ,
13
14
module Control.Exception.Lifted ,
14
15
module Control.Monad ,
16
+ module Control.Monad.Catch ,
15
17
module Control.Monad.Except ,
16
18
module Control.Monad.Identity ,
17
19
module Control.Monad.Reader ,
@@ -35,19 +37,24 @@ module NixFromNpm.Common (
35
37
module Control.Monad.Trans.Control ,
36
38
module System.Console.ANSI ,
37
39
Name , AuthToken , Record , (//) , (<>) ,
38
- uriToText , uriToString , putStrsLn , putStrs , dropSuffix , maybeIf , failC ,
40
+ uriToText , uriToString , putStrsLn , putStrs , maybeIf , failC ,
39
41
errorC , joinBy , mapJoinBy , getEnv , modifyMap , unsafeParseURI ,
40
42
parseURIText , withColor , withUL , warn , warns , assert , fatal , fatalC ,
41
43
partitionEither , throw , eitherToMaybe
44
+ #if !MIN_VERSION_mono_traversable(1,0,7)
45
+ , dropSuffix
46
+ #endif
42
47
) where
43
48
44
49
import ClassyPrelude hiding (assert , asList , find , FilePath , bracket ,
45
50
maximum , maximumBy , (</>) , (<>) ,
46
51
minimum , try , stripPrefix , ioError ,
47
52
mapM_ , sequence_ , foldM , forM_ , throw , throwIO ,
48
53
filterM , replicateM , writeFile , readFile ,
49
- writeFileUtf8 , readFileUtf8 )
54
+ writeFileUtf8 , readFileUtf8 , catch , catches ,
55
+ Handler )
50
56
import Control.Exception (throw )
57
+ import Control.Monad.Catch (catch , catches , Handler (.. ))
51
58
import qualified Prelude as P
52
59
import Control.Monad.RWS.Strict hiding (Any , (<>) )
53
60
import Control.Monad (when )
@@ -141,11 +148,13 @@ putStrsLn = putStrLn . concat
141
148
putStrs :: MonadIO m => [Text ] -> m ()
142
149
putStrs = putStr . concat
143
150
151
+ #if !MIN_VERSION_mono_traversable(1,0,7)
144
152
-- | Strip the given suffix from the given string.
145
153
dropSuffix :: Text -> Text -> Text
146
154
dropSuffix suffix input = case T. stripSuffix suffix input of
147
155
Nothing -> input
148
156
Just stripped -> stripped
157
+ #endif
149
158
150
159
-- | Return a Just value if the argument is True, else Nothing.
151
160
maybeIf :: Bool -> a -> Maybe a
0 commit comments