Skip to content

Spurious error when loading package into ghci #449

@dalejordan

Description

@dalejordan

I have a package which builds without error but fails to load in
ghci with a spurious parse error:

[Matrix] $ stack ghci Matrix
Configuring GHCi with the following packages: Matrix
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling MatrixInternal   ( /home/dale/stack/Matrix/MatrixInternal.hs, interpreted )
[2 of 2] Compiling Matrix           ( /home/dale/stack/Matrix/Matrix.hs, interpreted )

/home/dale/stack/Matrix/Matrix.hs:114:1:
    Parse error in pattern: (M (_) m v)     --NB. the inner "(_)" is "_" in the source file
Failed, modules loaded: MatrixInternal.
𝛌> :q

The code it is complaining about is:

(!) :: Matrix a -> (Int,Int) -> a
{-# INLINE (!) #-}
(M _ m v) ! ij = v V.! encode m ij

If I specify the major source file it just gives me the ghci prompt,
but I can load the load the modules OK.

[Matrix] $ stack ghci Matrix.hs
Configuring GHCi with the following packages: 
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
𝛌> :t shape

<interactive>:1:1: Not in scope: ‘shape’
𝛌> :l Matrix.hs
[1 of 2] Compiling MatrixInternal   ( MatrixInternal.hs, interpreted )
[2 of 2] Compiling Matrix           ( Matrix.hs, interpreted )
Ok, modules loaded: Matrix, MatrixInternal.
𝛌> :t shape
shape :: Matrix a -> (Int, Int)
𝛌> :q
Leaving GHCi.


[Matrix] $ stack --version
Version 0.1.1.0, Git revision 91fe70306f51eb3d68667a0d6e09a7d7ebbeb2b6

I suppose the latter behaviour is a feature of the stack environment,
but the parse error is mystifying.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions