Parse error of a function from qualified import in type signature
Summary
Parse error of a function from qualified import in type signature.
Steps to reproduce
B.hs
:
module B where
data Nat = Zero | Succ Nat
succ :: Nat -> Nat
succ = Succ
A.hs
:
module A where
import qualified B as N (Nat, succ)
data SomeType n = SomeConstructor n
someFunction :: SomeType n -> SomeType (N.succ n)
someFunction = undefined
ghc A.hs
:
ghc A.hs
Loaded package environment from /Users/ak3n/.ghc/x86_64-darwin-8.8.1/environments/default
[1 of 2] Compiling B ( B.hs, B.o )
[2 of 2] Compiling A ( A.hs, A.o )
A.hs:7:41: error: parse error on input ‘N.succ’
|
7 | someFunction :: SomeType n -> SomeType (N.succ n)
|
Removing N.
from N.succ
fixes the error.
UpdatedA.hs
:
module UpdatedA where
import qualified B as N (Nat, succ)
data SomeType n = SomeConstructor n
someFunction :: SomeType n -> SomeType (succ n)
someFunction = undefined
ghc UpdatedA.hs
:
ghc UpdatedA.hs
Loaded package environment from /Users/ak3n/.ghc/x86_64-darwin-8.8.1/environments/default
[1 of 2] Compiling B ( B.hs, B.o )
[2 of 2] Compiling UpdatedA ( UpdatedA.hs, UpdatedA.o )
Expected behavior
Expected a successful compilation in one case, and succ
is not in scope in another one.
Environment
- GHC version used:
8.8.1
8.10.1
Optional:
- Operating System:
macOS High sierra (10.13.6)
- System Architecture: x64