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 instances for Mutable t.f. for arrays from primitive #473

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

Shimuuar
Copy link
Contributor

@Shimuuar Shimuuar commented Dec 1, 2023

While arrays from primitive could not have Vector/MVector instances, Mutable is well defined for them. It's useful on its own and could be used with another pair of type classes.

While arrays from primitive could not have `Vector`/`MVector` instances,
`Mutable` is well defined for them. It's useful on its own and could be used
with another pair of type classes.
@Shimuuar
Copy link
Contributor Author

Shimuuar commented Mar 1, 2024

@lehins, @Bodigrim Any objections?

@lehins
Copy link
Contributor

lehins commented Mar 1, 2024

To be honest with you, I fail to see the usefulness of such type family instance for primitive types, but at the same time, I don't see anything wrong with it either.
It should work for all primitive arrays, except for ByteArray, since the kind does not match for it.

@Shimuuar
Copy link
Contributor Author

Shimuuar commented Mar 1, 2024

Main use is to provide standard type family for Vector/MVector like type classes which provide freezing/thawing etc. I don't quite figured it out.

In particular vector's type classes unify both slicing and array operations. If not for slicing, primitive's arrays could get Vector/MVector instances and could use all vector's machinery.

@lehins
Copy link
Contributor

lehins commented Mar 1, 2024

Maybe we should extract slicing functionality Vector v => Slicable v into a separate class?

@Bodigrim
Copy link
Contributor

Bodigrim commented Mar 1, 2024

To be honest with you, I fail to see the usefulness of such type family instance for primitive types, but at the same time, I don't see anything wrong with it either.

+1.

@Shimuuar
Copy link
Contributor Author

Shimuuar commented Mar 4, 2024

Maybe we should extract slicing functionality Vector v => Slicable v into a separate class?

It's something that I would like to do. But it's rather complicated, it's quite invasive change which will break all unboxed instances. There're functions like takeWhile which could be implemented in stream fusion framework and as a slice. API for creating slices is quite anemic too. I really should make a writeup about this

@Shimuuar Shimuuar merged commit 1ca259e into haskell:master Mar 18, 2024
19 checks passed
@Shimuuar Shimuuar deleted the primtive branch March 18, 2024 18:21
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

Successfully merging this pull request may close these issues.

3 participants