Ok, maybe I messed something up during installation of Haskell. So I completely removed Haskell as it was installed via GHCup. I use VSCode ++ HLS
Uninstall:
1: ghcup nuke
2: removed any ghcup lines in .bashrc
3: removed .stack, .ghc and .cabal files from my home directory
4: removed stack from /usr/local/bin directory.
Install:
1: copied and pasted “curl --proto ‘=https’ --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh”
2: followed the instruction on the terminal
New Project as per User guide - The Haskell Tool Stack
1: stack new helloworld new-template
2: cd helloworld
3: stack build
4: ghc --version :: The Glorious Glasgow Haskell Compilation System, version 8.10.7
5: stack setup
6: Modify Lib.hs according to Stack User guide Adding Dependencies
7: stack build
8: Adding -text to dependencies in package.yaml
dependencies:
- base >= 4.7 && < 5
- text
9: stack build
10: adding -filepath and - containers
dependencies:
- base >= 4.7 && < 5
- text
- filepath
- containers
11: stack build
12: add -classy-prelude to package.yaml
13: stack build.
14: Edit Lib.hs to:
{-# LANGUAGE OverloadedStrings #-}
module Lib
( someFunc
) where
import qualified Data.Text.IO as T
import ClassyPrelude
someFunc :: IO ()
someFunc = putStrLn "someFunc"
Note. When hover over ClassyPrelude I get the message
Could not find module ‘ClassyPrelude’
It is not a module in the current program, or in any known package.not found
15: Add - aeson and -random to package.yaml
dependencies:
- base >= 4.7 && < 5
- text
- filepath
- containers
- classy-prelude
- aeson
- random
16: Edit Lib.hs to:
{-# LANGUAGE OverloadedStrings #-}
module Lib
( someFunc
) where
import qualified Data.Text.IO as T
import ClassyPrelude
import System.Random
import Data.Aeson
someFunc :: IO ()
someFunc = putStrLn "someFunc"
Same Errors:
Could not find module ‘System.Random’
It is not a module in the current program, or in any known package.not found
Could not find module ‘Data.Aeson’
Perhaps you meant Data.Version (from base-4.14.3.0)not found
17: stack ls dependencies
Output:
OneTuple 0.3.1
QuickCheck 2.14.2
StateVar 1.2.2
adjunctions 4.4.1
aeson 2.0.3.0
array 0.5.4.0
assoc 1.0.2
async 2.2.4
attoparsec 0.14.4
base 4.15.1.0
base-compat 0.11.2
base-compat-batteries 0.11.2
base-orphans 0.8.6
basic-prelude 0.7.0
bifunctors 5.5.12
binary 0.8.8.0
bytestring 0.10.12.1
chunked-data 0.3.1
classy-prelude 1.5.0.2
comonad 5.0.8
containers 0.6.4.1
contravariant 1.5.5
data-default-class 0.1.2.0
data-fix 0.3.2
deepseq 1.4.5.0
directory 1.3.6.2
distributive 0.6.2.1
dlist 1.0
dlist-instances 0.1.1.1
exceptions 0.10.4
filepath 1.4.2.1
free 5.1.9
ghc-bignum 1.1
ghc-boot-th 9.0.2
ghc-prim 0.7.0
hashable 1.3.5.0
helloworld 0.1.0.0
indexed-traversable 0.1.2
indexed-traversable-instances 0.1.1
integer-logarithms 1.0.3.1
invariant 0.5.6
kan-extensions 5.2.5
keys 3.12.3
mono-traversable 1.0.15.3
mono-traversable-instances 0.1.1.0
mtl 2.2.2
mutable-containers 0.3.4
pointed 5.0.4
pretty 1.1.3.6
primitive 0.7.3.0
process 1.6.13.2
profunctors 5.6.2
random 1.2.1.1
rts 1.0.2
say 0.1.0.1
scientific 0.3.7.0
semialign 1.2.0.1
semigroupoids 5.3.7
semigroups 0.19.2
split 0.2.3.4
splitmix 0.1.0.4
stm 2.5.0.0
stm-chans 3.0.0.6
strict 0.4.0.1
tagged 0.8.6.1
template-haskell 2.17.0.0
text 1.2.5.0
text-short 0.1.5
th-abstraction 0.4.3.0
these 1.1.1.1
time 1.9.3
time-compat 1.9.6.1
transformers 0.5.6.2
transformers-base 0.4.6
transformers-compat 0.6.6
unix 2.7.2.2
unliftio 0.2.22.0
unliftio-core 0.2.0.1
unordered-containers 0.2.17.0
uuid-types 1.0.5
vector 0.12.3.1
vector-algorithms 0.8.0.4
vector-instances 3.4
void 0.7.3
witherable 0.4.2
Am I missing something???
Now, when I cd into src, run ghci and try to load Lib.hs I get this.
1: cd src
2: ghci
3: :l Lib.hs (does not compile)
GHCi, version 8.10.7: https://www.haskell.org/ghc/ :? for help
Prelude> :l Lib.hs
[1 of 1] Compiling Lib ( Lib.hs, interpreted )
Lib.hs:8:1: error:
Could not find module ‘ClassyPrelude’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
8 | import ClassyPrelude
| ^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude> :l Lib.hs
[1 of 1] Compiling Lib ( Lib.hs, interpreted )
Lib.hs:9:1: error:
Could not find module ‘System.Random’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
9 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
Lib.hs:10:1: error:
Could not find module ‘Data.Aeson’
Perhaps you meant Data.Version (from base-4.14.3.0)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
10 | import Data.Aeson
| ^^^^^^^^^^^^^^^^^
Failed, no modules loaded.