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

Products have Problematic Strictness #68

Open
BebeSparkelSparkel opened this issue May 28, 2024 · 4 comments
Open

Products have Problematic Strictness #68

BebeSparkelSparkel opened this issue May 28, 2024 · 4 comments
Labels
bug Something isn't working upstream The cause of the problem is elsewhere

Comments

@BebeSparkelSparkel
Copy link

BebeSparkelSparkel commented May 28, 2024

I tried using gap for the product explained in your paper Composing bidirectional programs monadically but the generic function has strictness in the parameters which caused the biparser drop bp = try bp *> drop bp <!> pure () to infinitely loop.

This is also problematic in base Data.Functor.Product.Product and I have detailed the problem more thoroughly in

haskell/core-libraries-committee#268

or

https://gitlab.haskell.org/ghc/ghc/-/issues/24898

This is probably a problem in more than just gap because I found with Product it to be a problem with

  • Applicative
  • Alternative
  • MonadPlus
  • MonadZip
  • Semigroup - impossible to create infinite data structures

so it would be worth checking those generic functions as well.

@Lysxia Lysxia added bug Something isn't working upstream The cause of the problem is elsewhere labels May 28, 2024
@Lysxia
Copy link
Owner

Lysxia commented May 28, 2024

Indeed, the instances for (:*:) (the GHC.Generics-specific variant of Product) are also too strict: https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src//GHC.Internal.Generics.html#local-6989586621679638273

This can only be fixed in base.

@BebeSparkelSparkel BebeSparkelSparkel changed the title Products have Problematic Strictness in the Second Parameter Products have Problematic Strictness May 28, 2024
@BebeSparkelSparkel
Copy link
Author

Thanks for pointing this out. Should this issue be closed?

@Lysxia
Copy link
Owner

Lysxia commented May 28, 2024

You can keep this open. Maybe there could be a local workaround or extra doc for this issue in generic-data while it gets resolved upstream.

@Lysxia
Copy link
Owner

Lysxia commented May 31, 2024

I wonder how useful the product of monads/applicatives really is. In our paper on bidirectional programming we mainly chose it for simplicity of exposition, but in practice I'd much prefer an approach based on polymorphism. Rather than constructing a biparser as a pair of parser and printer, we can write it as a polymorphic function parameterized by biparser primitives and instantiate it separately to parsers and printers (and possibly more).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream The cause of the problem is elsewhere
Projects
None yet
Development

No branches or pull requests

2 participants