haskell / os-string

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide coercions between OsString and WindowsString / PosixString

Bodigrim opened this issue · comments

It would be nice to have something like

import Data.Type.Coercion

coercionToPosixString :: Maybe (Coercion OsString PosixString)
#if defined(mingw32_HOST_OS)
coercionToPosixString = Nothing 
#else
coercionToPosixString = Just Coercion
#endif

and same for coercionToWindowsString :: Maybe (Coercion OsString WindowsString)

Names are inspired by aeson: coercionToHashMap and coercionToMap.

And same for OsChar / PosixChar / WindowsChar.

Even better would be to provide both coercions at the same time:

coercionToPosix :: Maybe (Coercion OsChar OsString, Coercion OsString PosixString)
coercionToWindows :: Maybe (Coercion OsChar WindowsString, Coercion OsString WindowsString)

What exactly are the semantics? Do we encode/decode? Is that really coercion?

So coercion from OsString to PosixString just fails on windows?

I'm not too familiar with that mechanism.

Can you provide a PR?