System.IO but not with Data.String?

Hi all, We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String. For an occasional IO action, this is obviously irrelevant but for a compiler, a build system, or anything else that does a lot of IO this seems like it would be(come) an issue. So I was wondering what would be involved in adding (portable) support for System.IO with an alternative to String (this alternative does not necessarily need to be Text or ByteString). I did a little bit of research into how GHC handles this and there appear to be several other String types in the GHC tree, including ByteString(?). How feasible is an alternative System.IO API? How tied to GHC would such an alternative need to be? To be clear, I am not looking to _replace_ System.IO but to _add_ an alternative API (and not a wrapper that maps to/from String). Please do not assume I necessarily know what I am talking about! Especially, when it comes to the "portable" part. :-) Cheers, Hilco

On Thu, 9 May 2024, Hilco Wijbenga wrote:
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
Maybe you are looking for the new versions of 'filepath' and 'directory' packages that use the OsString type from 'os-string'?

Perfect! Yes, that's exactly what I'm looking for. Amazing that I
completely missed that, it's not even that new.
On Thu, May 9, 2024 at 1:01 PM Henning Thielemann
On Thu, 9 May 2024, Hilco Wijbenga wrote:
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
Maybe you are looking for the new versions of 'filepath' and 'directory' packages that use the OsString type from 'os-string'?

See also a companion package https://hackage.haskell.org/package/file-io, which connects efficient and correct OsPath with ByteString-based readFile / writeFile. Best regards, Andrew
On 9 May 2024, at 21:22, Hilco Wijbenga
wrote: Perfect! Yes, that's exactly what I'm looking for. Amazing that I completely missed that, it's not even that new.
On Thu, May 9, 2024 at 1:01 PM Henning Thielemann
wrote: On Thu, 9 May 2024, Hilco Wijbenga wrote:
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
Maybe you are looking for the new versions of 'filepath' and 'directory' packages that use the OsString type from 'os-string'?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Ah, that looks very useful indeed, thank you.
On Fri, May 10, 2024 at 1:37 PM Andrew Lelechenko
See also a companion package https://hackage.haskell.org/package/file-io, which connects efficient and correct OsPath with ByteString-based readFile / writeFile.
Best regards, Andrew
On 9 May 2024, at 21:22, Hilco Wijbenga
wrote: Perfect! Yes, that's exactly what I'm looking for. Amazing that I completely missed that, it's not even that new.
On Thu, May 9, 2024 at 1:01 PM Henning Thielemann
wrote: On Thu, 9 May 2024, Hilco Wijbenga wrote:
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
Maybe you are looking for the new versions of 'filepath' and 'directory' packages that use the OsString type from 'os-string'?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

There is also e.g. the Data.Text.IO module from the text package, for doing
file I/O and other such things with Text instead of String.
-Brent
On Thu, May 9, 2024 at 2:29 PM Hilco Wijbenga
Hi all,
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
For an occasional IO action, this is obviously irrelevant but for a compiler, a build system, or anything else that does a lot of IO this seems like it would be(come) an issue. So I was wondering what would be involved in adding (portable) support for System.IO with an alternative to String (this alternative does not necessarily need to be Text or ByteString).
I did a little bit of research into how GHC handles this and there appear to be several other String types in the GHC tree, including ByteString(?). How feasible is an alternative System.IO API? How tied to GHC would such an alternative need to be? To be clear, I am not looking to _replace_ System.IO but to _add_ an alternative API (and not a wrapper that maps to/from String).
Please do not assume I necessarily know what I am talking about! Especially, when it comes to the "portable" part. :-)
Cheers, Hilco _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Yes, thank you. I was aware of that but AFAICT, it still uses FilePath
(i.e. String) and _that_ is what I want to avoid.
On Thu, May 9, 2024 at 6:33 PM Brent Yorgey
There is also e.g. the Data.Text.IO module from the text package, for doing file I/O and other such things with Text instead of String.
-Brent
On Thu, May 9, 2024 at 2:29 PM Hilco Wijbenga
wrote: Hi all,
We have Text and ByteString as alternatives to String but as soon as you want to do anything IO related (read a file, get a directory's content, et cetera) it seems your only option is to use String.
For an occasional IO action, this is obviously irrelevant but for a compiler, a build system, or anything else that does a lot of IO this seems like it would be(come) an issue. So I was wondering what would be involved in adding (portable) support for System.IO with an alternative to String (this alternative does not necessarily need to be Text or ByteString).
I did a little bit of research into how GHC handles this and there appear to be several other String types in the GHC tree, including ByteString(?). How feasible is an alternative System.IO API? How tied to GHC would such an alternative need to be? To be clear, I am not looking to _replace_ System.IO but to _add_ an alternative API (and not a wrapper that maps to/from String).
Please do not assume I necessarily know what I am talking about! Especially, when it comes to the "portable" part. :-)
Cheers, Hilco _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Do you instead want https://hackage.haskell.org/package/text-2.1.1/docs/Data-Text-IO.html ?

FWIW in the modern setting it’s much better to use https://hackage.haskell.org/package/text-2.1.1/docs/Data-Text-IO-Utf8.html Best regards, Andrew
On 10 May 2024, at 09:44, Dan Dart
wrote: Do you instead want https://hackage.haskell.org/package/text-2.1.1/docs/Data-Text-IO.html ? _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (5)
-
Andrew Lelechenko
-
Brent Yorgey
-
Dan Dart
-
Henning Thielemann
-
Hilco Wijbenga