-
Notifications
You must be signed in to change notification settings - Fork 5
Description
I'm very happy to find this repo and the Monday Morning Haskell Real World Haskel articles. This is exactly what I'm interested in learning more about: Haskell, Servant and Persistent for the backend and ELM for the frontend. Thank you!
I'm quite new to Haskell and not that familiar with Stack yet. Maybe there is something different between my system and your system. My machine is running macOS Catalina (10.15.7).
$> uname -v
Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64
$> stack --version
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
$> pwd
/Users/XXX/RealWorldHaskell
$> ls
LICENSE RealWorldHaskell.cabal app src stack.yaml.lock
README.md Setup.hs docker-compose.yml stack.yaml test
$>
When I try to start GHCI I get the following message:
$> stack ghci
* * * * * * * *
The main module to load is ambiguous. Candidates are:
1. Package `RealWorldHaskell' component RealWorldHaskell:exe:migrate-db with main-is file: /Users/XXX/RealWorldHaskell/app/MigrateDB.hs
2. Package `RealWorldHaskell' component RealWorldHaskell:exe:run-server with main-is file: /Users/XXX/RealWorldHaskell/app/RunServer.hs
You can specify which one to pick by:
* Specifying targets to stack ghci e.g. stack ghci RealWorldHaskell:exe:migrate-db
* Specifying what the main is e.g. stack ghci --main-is RealWorldHaskell:exe:migrate-db
* Choosing from the candidate above [1..2]
* * * * * * * *
Specify main module to use (press enter to load none):
I'm not sure if it matter which choice I make here. I try to continue by pressing enter (load none).
Not loading any main modules, as no valid module selected
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: RealWorldHaskell
GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /Users/XXX/RealWorldHaskell/.ghci
[ 1 of 10] Compiling BasicSchema ( /Users/XXX/RealWorldHaskell/src/BasicSchema.hs, interpreted )
[ 2 of 10] Compiling Cache ( /Users/XXX/RealWorldHaskell/src/Cache.hs, interpreted )
[ 3 of 10] Compiling Database ( /Users/XXX/RealWorldHaskell/src/Database.hs, interpreted )
[ 4 of 10] Compiling CacheServer ( /Users/XXX/RealWorldHaskell/src/CacheServer.hs, interpreted )
[ 5 of 10] Compiling BasicServer ( /Users/XXX/RealWorldHaskell/src/BasicServer.hs, interpreted )
[ 6 of 10] Compiling Paths_RealWorldHaskell ( /Users/XXX/RealWorldHaskell/.stack-work/dist/x86_64-osx/Cabal-3.0.1.0/build/autogen/Paths_RealWorldHaskell.hs, interpreted )
[ 7 of 10] Compiling SchemaEsq ( /Users/XXX/RealWorldHaskell/src/SchemaEsq.hs, interpreted )
[ 8 of 10] Compiling SampleObjects ( /Users/XXX/RealWorldHaskell/src/SampleObjects.hs, interpreted )
[ 9 of 10] Compiling DatabaseEsq ( /Users/XXX/RealWorldHaskell/src/DatabaseEsq.hs, interpreted )
[10 of 10] Compiling ServerEsq ( /Users/XXX/RealWorldHaskell/src/ServerEsq.hs, interpreted )
Ok, 10 modules loaded.
Loaded GHCi configuration from /private/var/folders/qb/sl7_9k8d2tvb5bjqtxhxj2jm0000gn/T/haskell-stack-ghci/be7d04e4/ghci-script
*ServerEsq BasicSchema BasicServer Cache CacheServer Database DatabaseEsq Paths_RealWorldHaskell SampleObjects SchemaEsq ServerEsq>
Next I use :l to to remove all modules so there are no name conflicts.
*ServerEsq BasicSchema BasicServer Cache CacheServer Database DatabaseEsq Paths_RealWorldHaskell SampleObjects SchemaEsq ServerEsq> :l
Ok, no modules loaded.
Prelude>
When I do import Database I get the following error.
Prelude> import Database
<interactive>:1:1: error:
attempting to use module ‘main:Database’ (/Users/karlmarklund/private/elm/RealWorldHaskell/src/Database.hs) which is not loaded
Prelude>
This seems to solve the above issue.
Prelude> :l Database
[1 of 2] Compiling BasicSchema ( /Users/karlmarklund/private/elm/RealWorldHaskell/src/BasicSchema.hs, interpreted )
[2 of 2] Compiling Database ( /Users/karlmarklund/private/elm/RealWorldHaskell/src/Database.hs, interpreted )
Ok, two modules loaded.
*Database>
Now I can start testing things out in GHCI.
*Database> localConnString
"host=127.0.0.1 port=5432 user=postgres dbname=postgres password=postgres"
*Database> :t migrateDB
migrateDB :: PGInfo -> IO ()
*Database>
Maybe this is expected behaviour? Or maybe I misunderstood your instructions or how to use Stack? Maybe you forgot to update your instructions? I leave this issue here for anyone else interested in learning from this repo and having similar problems.
Once again, thanks for sharing this learning resource. I hope I will be able to learn some Real World Haskell :-)