Different behaviour when working across different modules
josedusol opened this issue · comments
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:
However, if i put all these definitions inside the same module, there is no problem. How come?
You need to repeat the {-@ infixl 5 +. @-}
notation in the second module too, these notations are not imported.
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.
Thank you!
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.