How do you use Data.Text.intersperse :: Char -> Text -> Text?

I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`. Best regards, Andrew

`intersperse :: Char -> Text -> Text`
Yeah, that looks silly indeed. Should be pruned or marked as spam. On 2021-06-27 01:33, Andrew Lelechenko wrote:
I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`.
Best regards, Andrew _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On Sun, 27 Jun 2021 at 12:44, Andreas Abel
`intersperse :: Char -> Text -> Text`
Yeah, that looks silly indeed. Should be pruned or marked as spam.
"Spam" is a bit harsh. And it does indeed have some use (albeit primarily with test suites and quite possibly more efficient ways to do the required task anyway): https://github.com/search?l=Haskell&q=Text.intersperse&type=Code
On 2021-06-27 01:33, Andrew Lelechenko wrote:
I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`.
Best regards, Andrew _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com

More deeply, it doesn’t suffice to guarantee you’re gonna have a well formed unicode sequence! It’d need to be grapheme -> text -> text right? I’ve def wanted to dig into how to make programming more grapheme oriented for text at some point. I think swift explcitly does this in their standard libraries ? On Sun, Jun 27, 2021 at 1:37 AM Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote:
On Sun, 27 Jun 2021 at 12:44, Andreas Abel
wrote: `intersperse :: Char -> Text -> Text`
Yeah, that looks silly indeed. Should be pruned or marked as spam.
"Spam" is a bit harsh. And it does indeed have some use (albeit primarily with test suites and quite possibly more efficient ways to do the required task anyway): https://github.com/search?l=Haskell&q=Text.intersperse&type=Code
On 2021-06-27 01:33, Andrew Lelechenko wrote:
I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`.
Best regards, Andrew _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Carter, you might want to take a look at Elixir's standard library, which (in my experience) has a good position when it comes to graphemes https://hexdocs.pm/elixir/String.html Le 27/06/2021 à 15:58, Carter Schonwald a écrit :
More deeply, it doesn’t suffice to guarantee you’re gonna have a well formed unicode sequence!
It’d need to be grapheme -> text -> text right?
I’ve def wanted to dig into how to make programming more grapheme oriented for text at some point. I think swift explcitly does this in their standard libraries ?
On Sun, Jun 27, 2021 at 1:37 AM Ivan Lazar Miljenovic
mailto:ivan.miljenovic@gmail.com> wrote: On Sun, 27 Jun 2021 at 12:44, Andreas Abel
mailto:andreas.abel@ifi.lmu.de> wrote: > `intersperse :: Char -> Text -> Text`
Yeah, that looks silly indeed. Should be pruned or marked as spam.
"Spam" is a bit harsh. And it does indeed have some use (albeit primarily with test suites and quite possibly more efficient ways to do the required task anyway): https://github.com/search?l=Haskell&q=Text.intersperse&type=Code https://github.com/search?l=Haskell&q=Text.intersperse&type=Code
On 2021-06-27 01:33, Andrew Lelechenko wrote: > I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`. > > Best regards, > Andrew > _______________________________________________ > Libraries mailing list > Libraries@haskell.org mailto:Libraries@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com mailto:Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com http://IvanMiljenovic.wordpress.com _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Hécate ✨ 🐦: @TechnoEmpress IRC: Hecate WWW: https://glitchbra.in RUN: BSD

Cool!
Looks like the approach there is to not have a character type, but treat
code points as just tiny strings which can be mapped to integers?
I kind have this fuzzy idea Haskell and a lot of other languages use the
extended ascii character set in a sortah punned way that conflates binary
and textual data. And that’s ignoring how most western / native English
software folks naively treat chars as graphemes / atomic units of
rendering, when this falls apart when engineering for internationally
friendly software.
On Mon, Jun 28, 2021 at 3:43 AM Hécate
Carter, you might want to take a look at Elixir's standard library, which (in my experience) has a good position when it comes to graphemes https://hexdocs.pm/elixir/String.html Le 27/06/2021 à 15:58, Carter Schonwald a écrit :
More deeply, it doesn’t suffice to guarantee you’re gonna have a well formed unicode sequence!
It’d need to be grapheme -> text -> text right?
I’ve def wanted to dig into how to make programming more grapheme oriented for text at some point. I think swift explcitly does this in their standard libraries ?
On Sun, Jun 27, 2021 at 1:37 AM Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote:
On Sun, 27 Jun 2021 at 12:44, Andreas Abel
wrote: `intersperse :: Char -> Text -> Text`
Yeah, that looks silly indeed. Should be pruned or marked as spam.
"Spam" is a bit harsh. And it does indeed have some use (albeit primarily with test suites and quite possibly more efficient ways to do the required task anyway): https://github.com/search?l=Haskell&q=Text.intersperse&type=Code
On 2021-06-27 01:33, Andrew Lelechenko wrote:
I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`.
Best regards, Andrew _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com http://IvanMiljenovic.wordpress.com _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing listLibraries@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Hécate ✨ 🐦: @TechnoEmpress IRC: Hecate WWW: https://glitchbra.in RUN: BSD
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I have no idea whether that's useful at all. I added intersperse to
Data.Sequence because it has a really nice and efficient implementation in
terms of the Applicative instance for Seq. I have no idea if anyone uses it.
On Sat, Jun 26, 2021, 7:34 PM Andrew Lelechenko
I know applications for `intercalate :: Text -> [Text] -> Text`: `unwords`, `unlines`, etc. But what is `intersperse :: Char -> Text -> Text` good for? Am I correct assuming that its sole merit is to mimic `Data.List` API? Note that `Data.List.intersperse` is polymorphic and is exceedingly rarely used for `Char -> String -> String`.
Best regards, Andrew _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (6)
-
Andreas Abel
-
Andrew Lelechenko
-
Carter Schonwald
-
David Feuer
-
Hécate
-
Ivan Lazar Miljenovic