@@ -33,7 +33,13 @@ module System.OsString.MODULE_NAME
33
33
, unsafeEncodeUtf
34
34
, encodeWith
35
35
, encodeFS
36
+ #ifdef WINDOWS
37
+ , fromString
38
+ #endif
36
39
, fromBytes
40
+ #ifndef WINDOWS
41
+ , fromBytestring
42
+ #endif
37
43
, pstr
38
44
, singleton
39
45
, empty
@@ -254,6 +260,18 @@ encodeFS = fmap WindowsString . encodeWithBaseWindows
254
260
encodeFS = fmap PosixString . encodeWithBasePosix
255
261
#endif
256
262
263
+ #ifdef WINDOWS
264
+ -- | Like 'encodeFS', but not in IO.
265
+ --
266
+ -- 'encodeFS' was designed to have a symmetric type signature
267
+ -- on unix and windows, but morally the function has no IO effects on windows,
268
+ -- so we provide this variant without breaking existing API.
269
+ --
270
+ -- This function does not exist on unix.
271
+ fromString :: String -> WindowsString
272
+ fromString = unsafePerformIO . fmap WindowsString . encodeWithBaseWindows
273
+ #endif
274
+
257
275
258
276
#ifdef WINDOWS_DOC
259
277
-- | Partial unicode friendly decoding.
@@ -346,6 +364,18 @@ fromBytes bs =
346
364
fromBytes = pure . PosixString . BSP. toShort
347
365
#endif
348
366
367
+ #ifndef WINDOWS
368
+ -- | Like 'fromBytes', but not in IO.
369
+ --
370
+ -- 'fromBytes' was designed to have a symmetric type signature
371
+ -- on unix and windows, but morally the function has no IO effects on unix,
372
+ -- so we provide this variant without breaking existing API.
373
+ --
374
+ -- This function does not exist on windows.
375
+ fromBytestring :: ByteString -> PosixString
376
+ fromBytestring = PosixString . BSP. toShort
377
+ #endif
378
+
349
379
350
380
#ifdef WINDOWS_DOC
351
381
-- | QuasiQuote a 'WindowsString'. This accepts Unicode characters
0 commit comments