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

Erroneous assumption about lambda precedence in generated code #317

Open
bwbush opened this issue May 8, 2024 · 1 comment
Open

Erroneous assumption about lambda precedence in generated code #317

bwbush opened this issue May 8, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@bwbush
Copy link

bwbush commented May 8, 2024

Code like

instance
  iMaybeHashable : ⦃ i : Hashable a ⦄  Hashable (Maybe a)
  iMaybeHashable {{_}} .hash Nothing = MakeHash ∘ hashBytes $ hash iUnitHashable tt
  iMaybeHashable {{i}} .hash (Just x) = MakeHash ∘ hashBytes $ hash iPairHashable (tt , x)
{-# COMPILE AGDA2HS iMaybeHashable #-}

becomes the uncompilable

instance (Hashable a) => Hashable (Maybe a) where
    hash Nothing = MakeHash . \ r -> hashBytes r $ hash ()
    hash (Just x) = MakeHash . \ r -> hashBytes r $ hash ((), x)

instead of the correct

instance (Hashable a) => Hashable (Maybe a) where
    hash Nothing = MakeHash . (\ r -> hashBytes r) $ hash ()
    hash (Just x) = MakeHash . (\ r -> hashBytes r) $ hash ((), x)
@jespercockx jespercockx added the bug Something isn't working label May 9, 2024
@jespercockx jespercockx added this to the 1.4 milestone May 9, 2024
@jespercockx
Copy link
Member

Our current pretty-printing library is not very consistent with parenthesis, @flupe has suggested we change to ghc-src-gen: #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants