@@ -166,13 +166,11 @@ import Control.Monad.Catch (MonadThrow(..))
166166import Data.Bifunctor (bimap )
167167import Data.Functor.Identity (Identity (.. ))
168168import Data.Maybe (fromJust )
169- import Data.Word (Word8 )
170- #if defined(IS_WINDOWS)
171- import Data.Word (Word16 )
172- #endif
173169#ifndef IS_WINDOWS
170+ import Data.Word (Word8 )
174171import Foreign.C (CString )
175172#else
173+ import Data.Word (Word16 )
176174import Foreign.C (CWString )
177175#endif
178176import Language.Haskell.TH.Syntax (lift )
@@ -304,11 +302,7 @@ addTrailingSeparator p = unsafeAppend p sep
304302
305303-- | Throws an exception if the path is not valid. See 'isValidPath' for the
306304-- list of validations.
307- #ifndef IS_WINDOWS
308- validatePath :: MonadThrow m => Array Word8 -> m ()
309- #else
310- validatePath :: MonadThrow m => Array Word16 -> m ()
311- #endif
305+ validatePath :: MonadThrow m => Array WORD_TYPE -> m ()
312306validatePath = Common. validatePath Common. OS_NAME
313307
314308#ifndef IS_WINDOWS
@@ -322,7 +316,7 @@ validatePath = Common.validatePath Common.OS_NAME
322316-- >>> isValid "\0"
323317-- False
324318--
325- isValidPath :: Array Word8 -> Bool
319+ isValidPath :: Array WORD_TYPE -> Bool
326320isValidPath = Common. isValidPath Common. OS_NAME
327321#endif
328322
@@ -342,11 +336,7 @@ isValidPath = Common.isValidPath Common.OS_NAME
342336-- per 'isValidPath'.
343337--
344338{-# INLINE unsafeFromChunk #-}
345- #ifndef IS_WINDOWS
346- unsafeFromChunk :: IsPath OS_PATH a => Array Word8 -> a
347- #else
348- unsafeFromChunk :: IsPath OS_PATH a => Array Word16 -> a
349- #endif
339+ unsafeFromChunk :: IsPath OS_PATH a => Array WORD_TYPE -> a
350340unsafeFromChunk =
351341#ifndef DEBUG
352342 unsafeFromPath . OS_PATH . Common. unsafeFromChunk
@@ -359,11 +349,7 @@ unsafeFromChunk =
359349-- | Convert a byte array into a Path.
360350-- Throws 'InvalidPath' if 'isValidPath' fails on the path.
361351--
362- #ifndef IS_WINDOWS
363- fromChunk :: (MonadThrow m , IsPath OS_PATH a ) => Array Word8 -> m a
364- #else
365- fromChunk :: (MonadThrow m , IsPath OS_PATH a ) => Array Word16 -> m a
366- #endif
352+ fromChunk :: (MonadThrow m , IsPath OS_PATH a ) => Array WORD_TYPE -> m a
367353fromChunk arr = Common. fromChunk Common. OS_NAME arr >>= fromPath . OS_PATH
368354
369355-- XXX Should be a Fold instead?
@@ -391,11 +377,7 @@ fromChars s =
391377
392378-- | Create a raw path i.e. an array representing the path. Note that the path
393379-- is not validated, therefore, it may not be valid according to 'isValidPath'.
394- #ifndef IS_WINDOWS
395- rawFromString :: [Char ] -> Array Word8
396- #else
397- rawFromString :: [Char ] -> Array Word16
398- #endif
380+ rawFromString :: [Char ] -> Array WORD_TYPE
399381rawFromString =
400382 Common. unsafeFromChars Unicode. UNICODE_ENCODER
401383 . Stream. fromList
@@ -472,9 +454,9 @@ path = mkQ pathE
472454
473455-- XXX unPath?
474456
475- -- | Convert the path to an array of bytes .
476- toChunk :: IsPath OS_PATH a => a -> Array Word8
477- toChunk p = let OS_PATH arr = toPath p in Common. toChunk arr
457+ -- | Convert the path to an array.
458+ toChunk :: IsPath OS_PATH a => a -> Array WORD_TYPE
459+ toChunk p = let OS_PATH arr = toPath p in arr
478460
479461-- | Decode the path to a stream of Unicode chars using strict CODEC_NAME decoding.
480462{-# INLINE toChars #-}
0 commit comments