I've started writing a typeclass for all conversions:
class ToOS a b where
toOS :: a -> b
instance ToOS ByteString OsString where
toOS = OsString . toOS
instance ToOS PosixPath OsString where
toOS = OsString
instance ToOS ByteString PosixPath where
toOS = coerce . BSS.toShort
instance ToOS PosixPath ByteString where
toOS = BSS.fromShort . coerce
...
Then I've realized that some of the conversions would raise an exception like FilePath -> m PosixPath.
On top of that, a lot of these conversions are O(n) and now each library has to implement all the different interfaces.
Doesn't that smell like there should be a OsString typeclass for common operations just like we have Num?
class OsString a where
pathSeparator :: a
pathSeparators :: [a]
...
I've started writing a typeclass for all conversions:
Then I've realized that some of the conversions would raise an exception like
FilePath -> m PosixPath.On top of that, a lot of these conversions are
O(n)and now each library has to implement all the different interfaces.Doesn't that smell like there should be a
OsStringtypeclass for common operations just like we haveNum?