If i write import in .hs file, it pops error saying no module found for "Lib" and "import Numeric.LinearAlgebra ( (><), linearSolve )". Also i got error saying ambiguous type.
src/Lib.hs
module Lib where
import Numeric.LinearAlgebra ( (><), linearSolve )
c = (2><2) [ 1.0, 2.0 , 3.0, 5.0 ]
d = (2><3) [ 6.0, 1.0, 10.0 , 15.0, 3.0, 26.0 ]
someFunc :: IO ()
someFunc = do
putStrLn "someFunc"
print c
app/Main.hs
module Main (main) where
import Lib
main :: IO ()
main = someFunc
Error 1 : Could not find module "Numeric.LinearAlgebra" and "Lib" (Error shows in VS code)
Error 2 : ambiguous type
I:\\haskellFiles\aet11\src\Lib.hs:5:6: error:
* Ambiguous type variable `a1' arising from a use of `><'
prevents the constraint `(Foreign.Storable.Storable
a1)' from being solved.
Relevant bindings include
c :: hmatrix-0.20.2:Internal.Matrix.Matrix a1
(bound at I:\\haskellFiles\aet11\src\Lib.hs:5:1)
Probable fix: use a type annotation to specify what `a1' should be.
These potential instances exist:
instance Foreign.Storable.Storable ()
-- Defined in `Foreign.Storable'
instance Foreign.Storable.Storable Bool
-- Defined in `Foreign.Storable'
instance Foreign.Storable.Storable Char
-- Defined in `Foreign.Storable'
...plus four others
...plus 40 instances involving out-of-scope types
(use -fprint-potential-instances
to see them all)
* In the expression: 2 >< 2
In the expression: (2 >< 2) [1.0, 2.0, 3.0, 5.0]
In an equation for `c': c = (2 >< 2) [1.0, 2.0, 3.0, ....]
|
5 | c = (2><2) [ 1.0, 2.0 , 3.0, 5.0 ]
| ^^^^
I:\\haskellFiles\aet11\src\Lib.hs:5:14: error:
* Ambiguous type variable `a1' arising from the literal `1.0'
prevents the constraint `(Fractional a1)' from being solved.
Relevant bindings include
c :: hmatrix-0.20.2:Internal.Matrix.Matrix a1
(bound at I:\\haskellFiles\aet11\src\Lib.hs:5:1)
Probable fix: use a type annotation to specify what `a1' should be.
These potential instances exist:
instance Fractional Double -- Defined in `GHC.Float'
instance Fractional Float -- Defined in `GHC.Float'
...plus six instances involving out-of-scope types
(use -fprint-potential-instances
to see them all)
* In the expression: 1.0
In the first argument of `2 >< 2',
namely `[1.0, 2.0, 3.0, 5.0]'
In the expression: (2 >< 2) [1.0, 2.0, 3.0, 5.0]
|
5 | c = (2><2) [ 1.0, 2.0 , 3.0, 5.0 ]
However, if i import it only in ghci, that works just fine
Image writing syntax directly in ghci
I have tried using stack repl, stack ghci, stack build. Tried reinstall Haskell, delete /sr/ and /Programs/stack/ and reinstall stack, reinstall vs code extension Haskell, Haskelly and Haskell Syntax Highlighting. Didn't solve the problem.