Skip to content

Commit da729ec

Browse files
committed
Minimize __MHS__ differences.
1 parent 3e3fe72 commit da729ec

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

System/OsPath/Common.hs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ module System.OsPath
4545
, PS.unsafeEncodeUtf
4646
, PS.encodeWith
4747
, encodeFS
48-
#if !defined(__MHS__)
4948
#if defined(WINDOWS) || defined(POSIX)
5049
, pstr
5150
#else
5251
, osp
5352
#endif
54-
#endif /* !defined(__MHS__) */
5553
, PS.pack
5654

5755
-- * Filepath deconstruction
@@ -126,26 +124,22 @@ import System.OsString.Windows as PS
126124
import Data.Bifunctor ( bimap )
127125
import qualified System.OsPath.Windows.Internal as C
128126
import GHC.IO.Encoding.UTF16 ( mkUTF16le )
129-
#if !defined(__MHS__)
130127
import Language.Haskell.TH.Quote
131128
( QuasiQuoter (..) )
132129
import Language.Haskell.TH.Syntax
133130
( Lift (..), lift )
134-
#endif
135131
import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
136132
import Control.Monad ( when )
137133

138134
#elif defined(POSIX)
139135
import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
140136
import Control.Monad ( when )
141-
#if !defined(__MHS__)
142137
import Language.Haskell.TH.Quote
143138
( QuasiQuoter (..) )
144139
import Language.Haskell.TH.Syntax
145140
( Lift (..), lift )
146-
#endif
147-
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
148141

142+
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
149143
import System.OsPath.Types
150144
import System.OsString.Posix as PS
151145
( unsafeFromChar
@@ -164,16 +158,14 @@ import qualified System.OsPath.Posix.Internal as C
164158
#else
165159

166160
import System.OsPath.Internal as PS
167-
( decodeUtf
161+
( osp
162+
, decodeUtf
168163
, decodeWith
169164
, pack
170165
, encodeUtf
171166
, unsafeEncodeUtf
172167
, encodeWith
173168
, unpack
174-
#if !defined(__MHS__)
175-
, osp
176-
#endif
177169
)
178170
import System.OsPath.Types
179171
( OsPath )

System/OsPath/Internal.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ import Control.Monad.Catch
1515
( MonadThrow )
1616
import Data.ByteString
1717
( ByteString )
18-
#if !defined(__MHS__)
1918
import Language.Haskell.TH.Quote
2019
( QuasiQuoter (..) )
2120
import Language.Haskell.TH.Syntax
2221
( Lift (..), lift )
23-
import System.IO
24-
( TextEncoding )
25-
#else
26-
import GHC.IO.Encoding.Types ( TextEncoding )
27-
#endif
2822
import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
2923

3024
import System.OsString.Internal.Types
3125
import System.OsPath.Encoding
3226
import Control.Monad (when)
27+
#if !defined(__MHS__)
28+
import System.IO
29+
( TextEncoding )
30+
#else
31+
import GHC.IO.Encoding.Types ( TextEncoding )
32+
#endif
3333

3434
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
3535
import qualified System.OsPath.Windows as PF
@@ -128,7 +128,7 @@ fromBytes = OS.fromBytes
128128

129129

130130

131-
#if !defined(__MHS__)
131+
#if defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter)
132132
-- | QuasiQuote an 'OsPath'. This accepts Unicode characters
133133
-- and encodes as UTF-8 on unix and UTF-16LE on windows. Runs 'isValid'
134134
-- on the input. If used as a pattern, requires turning on the @ViewPatterns@
@@ -164,7 +164,10 @@ osp = QuasiQuoter
164164
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a declaration)"
165165
}
166166
#endif
167-
#endif /* !defined(__MHS__) */
167+
#else
168+
osp :: a
169+
osp = error "Systen.OsPath.Internal.ostr: no Template Haskell"
170+
#endif /* defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter) */
168171

169172

170173
-- | Unpack an 'OsPath' to a list of 'OsChar'.

System/OsPath/Posix.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "Common.hs"
1313

14-
#if !defined(__MHS__)
14+
#if defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter)
1515
-- | QuasiQuote a 'PosixPath'. This accepts Unicode characters
1616
-- and encodes as UTF-8. Runs 'isValid' on the input.
1717
pstr :: QuasiQuoter
@@ -30,5 +30,8 @@ pstr =
3030
, quoteDec = \_ ->
3131
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a declaration)"
3232
}
33-
#endif /* !defined(__MHS__) */
33+
#else
34+
pstr :: a
35+
pstr = error "Systen.OsPath.Posix.pstr: no Template Haskell"
36+
#endif /* defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter) */
3437

System/OsPath/Windows.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "Common.hs"
1313

14-
#if !defined(__MHS__)
14+
#if defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter)
1515
-- | QuasiQuote a 'WindowsPath'. This accepts Unicode characters
1616
-- and encodes as UTF-16LE. Runs 'isValid' on the input.
1717
pstr :: QuasiQuoter
@@ -30,4 +30,7 @@ pstr =
3030
, quoteDec = \_ ->
3131
fail "illegal QuasiQuote (allowed as expression or pattern only, used as a declaration)"
3232
}
33-
#endif /* !defined(__MHS__) */
33+
#else
34+
pstr :: a
35+
pstr = error "Systen.OsPath.Windows.pstr: no Template Haskell"
36+
#endif /* defined(MIN_VERSION_template_haskell) || defined(MIN_VERSION_template_haskell_quasi_quoter) */

0 commit comments

Comments
 (0)