Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intersperse #114

Closed
i-am-the-slime opened this issue May 21, 2020 · 3 comments
Closed

Add intersperse #114

i-am-the-slime opened this issue May 21, 2020 · 3 comments

Comments

@i-am-the-slime
Copy link

Every once in a while, I find myself needing this.
Then I find this again. And then I go look it up here.

I don't know about the performance characteristics but I could translate the Haskell version into PS.

@i-am-the-slime
Copy link
Author

Maybe it doesn't belong here, but to Array and friends?

@hdgarrood
Copy link
Contributor

I agree, I’ve wanted this too, and using intercalate is less than ideal, not only because it’s slower, but also because I find it’s surprisingly hard to work out how to get the types to line up to get it to do what I want. I think adding monomorphic forall a. a -> T a -> T a functions for T = Array, List, etc would be the way to go. Foldable doesn’t quite seem appropriate because it doesn’t really give you a good way of preserving structure; I think an implementation in terms of Foldable would have to rely on a Semigroup instance which does concatenation.

@hdgarrood
Copy link
Contributor

I'll close this as I think it's covered by purescript/purescript-arrays#15 and purescript/purescript-lists#132, and we wouldn't put these functions in this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants