os-string as a typeclass?
- Dominant language
- Haskell
- Stars
- 7
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
I've started writing a typeclass for all conversions:
```haskell
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`?
```haskell
class OsString a where
pathSeparator :: a
pathSeparators :: [a]
...
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.