Skip to content

Commit 56f1543

Browse files
committed
Make error strings consistent
System.Posix.ByteString.FilePath just unpacks, while System.Posix.PosixPath.FilePath tried to be smart and decode with UTF (without failing). This divergence was discussed here: * #279 * haskell/core-libraries-committee#189
1 parent b104a7f commit 56f1543

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

System/Posix/PosixPath/FilePath.hsc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ import Foreign.C hiding (
4040

4141
import System.OsPath.Types
4242
import Control.Monad
43-
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
44-
import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
45-
import System.OsPath.Posix
43+
import System.OsPath.Posix as PS
4644
import System.OsPath.Data.ByteString.Short
4745
import Prelude hiding (FilePath)
4846
import System.OsString.Internal.Types (PosixString(..))
47+
4948
#if !MIN_VERSION_base(4, 11, 0)
5049
import Data.Monoid ((<>))
5150
#endif
@@ -136,5 +135,5 @@ throwErrnoTwoPathsIfMinus1_ loc path1 path2 =
136135

137136

138137
_toStr :: PosixPath -> String
139-
_toStr fp = either (error . show) id $ decodeWith (mkUTF8 TransliterateCodingFailure) fp
138+
_toStr = fmap PS.toChar . PS.unpack
140139

0 commit comments

Comments
 (0)