@@ -34,7 +34,13 @@ module System.OsString.MODULE_NAME
34
34
, encodeWith
35
35
, encodeFS
36
36
, encodeLE
37
+ #ifdef WINDOWS
38
+ , fromString
39
+ #endif
37
40
, fromBytes
41
+ #ifndef WINDOWS
42
+ , fromBytestring
43
+ #endif
38
44
, pstr
39
45
, singleton
40
46
, empty
@@ -289,6 +295,19 @@ encodeLE = fmap WindowsString . encodeWithBaseWindows
289
295
encodeLE = fmap PosixString . encodeWithBasePosix'
290
296
#endif
291
297
298
+ #ifdef WINDOWS
299
+ -- | Like 'encodeFS', but not in IO.
300
+ --
301
+ -- 'encodeFS' was designed to have a symmetric type signature
302
+ -- on unix and windows, but morally the function has no IO effects on windows,
303
+ -- so we provide this variant without breaking existing API.
304
+ --
305
+ -- This function does not exist on unix.
306
+ --
307
+ -- @since 2.0.6
308
+ fromString :: String -> WindowsString
309
+ fromString = unsafePerformIO . fmap WindowsString . encodeWithBaseWindows
310
+ #endif
292
311
293
312
#ifdef WINDOWS_DOC
294
313
-- | Partial unicode friendly decoding.
@@ -405,6 +424,20 @@ fromBytes bs =
405
424
fromBytes = pure . PosixString . BSP. toShort
406
425
#endif
407
426
427
+ #ifndef WINDOWS
428
+ -- | Like 'fromBytes', but not in IO.
429
+ --
430
+ -- 'fromBytes' was designed to have a symmetric type signature
431
+ -- on unix and windows, but morally the function has no IO effects on unix,
432
+ -- so we provide this variant without breaking existing API.
433
+ --
434
+ -- This function does not exist on windows.
435
+ --
436
+ -- @since 2.0.6
437
+ fromBytestring :: ByteString -> PosixString
438
+ fromBytestring = PosixString . BSP. toShort
439
+ #endif
440
+
408
441
409
442
#ifdef WINDOWS_DOC
410
443
-- | QuasiQuote a 'WindowsString'. This accepts Unicode characters
0 commit comments