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

Wrong type for with(Mutable)PrimArrayContents #404

Open
Rotaerk opened this issue Dec 23, 2023 · 2 comments
Open

Wrong type for with(Mutable)PrimArrayContents #404

Rotaerk opened this issue Dec 23, 2023 · 2 comments

Comments

@Rotaerk
Copy link

Rotaerk commented Dec 23, 2023

The withMutablePrimArrayContents and withPrimArrayContents functions take a Ptr a -> m a, which restricts you to only returning an a. Best guess as to why this might have been done is to prevent the return of the pointer itself, but... it prevents the return of everything else too ... Why not change them to (Ptr a -> m b) -> m b?

@chessai
Copy link
Member

chessai commented Dec 23, 2023

The withMutablePrimArrayContents and withPrimArrayContents functions take a Ptr a -> m a, which restricts you to only returning an a. Best guess as to why this might have been done is to prevent the return of the pointer itself, but... it prevents the return of everything else too ... Why not change them to (Ptr a -> m b) -> m b?

Makes sense to me - would take a PR

@andrewthad
Copy link
Collaborator

Darn. This was a mistake. Fortunately, changing the result type from a to b is nonbreaking even for users of TypeApplications since GHC will infer b to be the last type argument (i.e. forall (m :: Type -> Type) (a :: Type) (b :: Type).). We should release this soon after it's fixed.

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

3 participants