I recently read about FRP and became interested in Yampa. Because I have already installed it, here I just check its installation. When I follow the instructions
$ cabal sandbox init # Optional, but recommended
$ cabal update
$ cabal install Yampa
The result of the third step is:
cabal install Yampa
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: Yampa. Perhaps you want to use --lib to install libraries instead.
So I add --lib and get:
cabal install Yampa --lib
Resolving dependencies...
Up to date
Then I turned to Vscode and write a line:
import FRP.Yampa
What I get is:
error:
Could not find module ‘FRP.Yampa’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
3 | import FRP.Yampa
I didn't give up and used "ghc -v Yampa" to search for the package:
wired-in package ghc-prim mapped to ghc-prim-0.5.3
wired-in package integer-wired-in mapped to integer-gmp-1.0.2.0
wired-in package base mapped to base-4.13.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.15.0.0
wired-in package ghc mapped to ghc-8.8.3
package flags [-package-id ghc-8.8.3{unit ghc-8.8.3 True ([])},
-package-id bytestring-0.10.10.0{unit bytestring-0.10.10.0 True ([])},
-package-id unix-2.7.2.2{unit unix-2.7.2.2 True ([])},
-package-id base-4.13.0.0{unit base-4.13.0.0 True ([])},
-package-id time-1.9.3{unit time-1.9.3 True ([])},
-package-id hpc-0.6.0.3{unit hpc-0.6.0.3 True ([])},
-package-id filepath-1.4.2.1{unit filepath-1.4.2.1 True ([])},
-package-id process-1.6.8.0{unit process-1.6.8.0 True ([])},
-package-id array-0.5.4.0{unit array-0.5.4.0 True ([])},
-package-id integer-gmp-1.0.2.0{unit integer-gmp-1.0.2.0 True ([])},
-package-id containers-0.6.2.1{unit containers-0.6.2.1 True ([])},
-package-id ghc-boot-8.8.3{unit ghc-boot-8.8.3 True ([])},
-package-id binary-0.8.7.0{unit binary-0.8.7.0 True ([])},
-package-id ghc-prim-0.5.3{unit ghc-prim-0.5.3 True ([])},
-package-id ghci-8.8.3{unit ghci-8.8.3 True ([])},
-package-id rts{unit rts-1.0 True ([])},
-package-id terminfo-0.4.1.4{unit terminfo-0.4.1.4 True ([])},
-package-id transformers-0.5.6.2{unit transformers-0.5.6.2 True ([])},
-package-id deepseq-1.4.4.0{unit deepseq-1.4.4.0 True ([])},
-package-id ghc-boot-th-8.8.3{unit ghc-boot-th-8.8.3 True ([])},
-package-id pretty-1.1.3.6{unit pretty-1.1.3.6 True ([])},
-package-id template-haskell-2.15.0.0{unit template-haskell-2.15.0.0 True ([])},
-package-id directory-1.3.6.0{unit directory-1.3.6.0 True ([])},
-package-id text-1.2.4.0{unit text-1.2.4.0 True ([])},
-package-id Ymp-0.13.1-433f4ae2{unit Yampa-0.13.1 True ([])}]
Obviously the last line above is Yampa, but what follows is:
loading package database /usr/local/Cellar/ghc/8.8.3/lib/ghc-8.8.3/package.conf.d
loading package database /Users/.cabal/store/ghc-8.8.3/package.db
wired-in package ghc-prim mapped to ghc-prim-0.5.3
wired-in package integer-wired-in mapped to integer-gmp-1.0.2.0
wired-in package base mapped to base-4.13.0.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.15.0.0
wired-in package ghc mapped to ghc-8.8.3
*** Chasing dependencies:
Chasing modules from: *Yampa
<no location info>: error: module ‘Yampa’ cannot be found locally
I've been trying to solve this problem but there seems to be no questions related to my situation. So I really need your help. Thanks!
--------------------------------------------------------update_2020_05_03------------------------------------------------
The file was directly created (without using "stack new "). That means, I just create a text file, put a line "import FRP.Yampa" and change its name to helloworld.hs in a folder "haskell_code" in VScode.
However, if I use "stack new mystic" to create a project called mystic. and go to its main.hs. I still cannot find FRP.Yampa. This time the error message when I run it is a little different:
error:
Could not load module ‘FRP.Yampa’
It is a member of the hidden package ‘Yampa-0.13.1’.
You can run ‘:set -package Yampa’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import FRP.Yampa
Therefore, I modified the mystic.cabal file by adding Yampa to its build-depends (I didn't use ‘:set -package Yampa’ because every time I have to input that things)
I got the following information:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for mystic-0.1.0.0:
Yampa needed, but the stack configuration has no specified version (latest matching version
is 0.13.1)
needed since mystic is a build target.
Some different approaches to resolving this:
* Recommended action: try adding the following to your extra-deps
in /Users/zhangkai/mystic/stack.yaml:
- Yampa-0.13.1@sha256:4612a2646c27bcd3ac55c90dbc34249303e28aa5b3bc3e0c6fa9ce58b889843c,5436
Error: Plan construction failed.
Warning: Build failed, but trying to launch GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: mystic
GHCi, version 8.8.3: https://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package Yampa
(use -v for more information)
And I took its advice by adding the line to the extra-deps of stack.yaml
extra-deps:
- Yampa-0.13.1@sha256:4612a2646c27bcd3ac55c90dbc34249303e28aa5b3bc3e0c6fa9ce58b889843c,5436
It works. Also I tried some other packages. If I create a single .hs file, I fail. If I create a project and modify its .cabal and .yaml, it works. I guess perhaps it has something to do with the environment. Those packages are downloaded but hidden.
So my question here would be: is there any workaround that allows the packages to be seen by even a single .hs file (Obviously it has neither .cabal nor .yaml)?