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

Different behaviour when working across different modules #2217

Open
josedusol opened this issue Sep 10, 2023 · 4 comments
Open

Different behaviour when working across different modules #2217

josedusol opened this issue Sep 10, 2023 · 4 comments

Comments

@josedusol
Copy link

Hello. Let's say we have a first module:

module TestA where

import Prelude (Show)

data N where { O :: N; S :: N -> N }
  deriving (Show)

{-@ infixl 5 +. @-}   
{-@ reflect +. @-}
{-@ (+.) :: N -> N -> N @-}
(+.) = \m n -> case m of { O -> n; S k -> S (k +. n) }

and a second module importing previous one

module TestB where

import Language.Haskell.Liquid.Equational
import Prelude (Show)
import TestA

data List a where { E :: List a; C :: a -> List a -> List a }
  deriving (Show)

{-@ reflect length @-}
{-@ length :: List a -> N @-}
length :: List a -> N
length = \l -> case l of { E -> O; x`C`xs -> S (length xs) }

{-@ infixl 7 ++ @-}   
{-@ reflect ++ @-}
{-@ (++) :: List a -> List a -> List a @-}
(++) :: List a -> List a -> List a
(++) = \l1 l2 -> case l1 of { E -> l2; x`C`xs -> x `C` (xs ++ l2) }

{-@ lemma :: l1:List a -> l2:List a -> { length (l1 ++ l2) = (length l1) +. (length l2) } @-}
lemma :: List a -> List a -> Proof
-- proof here

I see the following parsing error concering the +. operator in the lemma declaration:
image

However, if i put all these definitions inside the same module, there is no problem. How come?

@nikivazou
Copy link
Member

You need to repeat the {-@ infixl 5 +. @-} notation in the second module too, these notations are not imported.

@facundominguez
Copy link
Collaborator

Maybe the error message could suggest that an infix declaration is missing. This wouldn't be a difficult contribution, I think.

Propagating infix declarations when importing modules would be a bit harder. Also, some care is necessary to check that the infix declarations can qualify the operators to disambiguate them when there are multiple definitions in a project.

@josedusol
Copy link
Author

Thank you!

@josedusol
Copy link
Author

Maybe the error message could suggest that an infix declaration is missing. This wouldn't be a difficult contribution, I think.

Yeah, the "cannot parse specification" message is of little help.

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

No branches or pull requests

3 participants