我已经安装了Yampa,但是无法导入FRP。Yampa(Mac OS Catalina)

时间:2020-05-02 07:46:40

标签: haskell ghc cabal frp yampa

我最近阅读了有关FRP的内容,并对Yampa感兴趣。因为我已经安装了它,所以在这里我只检查它的安装。当我按照说明进行操作

$ cabal sandbox init         # Optional, but recommended
$ cabal update
$ cabal install Yampa

第三步的结果是:

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.

所以我添加--lib并得到:

cabal install Yampa --lib
Resolving dependencies...
Up to date

然后我转向Vscode并写一行:

import FRP.Yampa

我得到的是:

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

我没有放弃,而是使用“ ghc -v Yampa”来搜索软件包:

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 ([])}]

显然上面的最后一行是Yampa,但接下来是:

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

我一直在尝试解决此问题,但似乎没有与我的情况有关的问题。所以我真的需要你的帮助。谢谢!

--------------------------------------------------- --------- update_2020_05_03 ---------------------------------------- --------

文件是直接创建的(不使用“ stack new”)。这就是说,我只创建一个文本文件,在“导入FRP.Yampa”行中放入VScode中的“ haskell_code”文件夹,并将其名称更改为helloworld.hs。

但是,如果我使用“ stack new mystic”来创建一个名为mystic的项目。并转到其main.hs。我仍然找不到FRP.Yampa。这次我运行时的错误消息有所不同:

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

因此,我通过在其构建依赖项中添加Yampa来修改了mystic.cabal文件(我没有使用``:set -package Yampa”,因为每次必须输入这些内容)

我得到以下信息:

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)

然后我将其行添加到stack.yaml的下垂行中

extra-deps:
- Yampa-0.13.1@sha256:4612a2646c27bcd3ac55c90dbc34249303e28aa5b3bc3e0c6fa9ce58b889843c,5436

有效。我也尝试了其他一些软件包。如果我创建一个.hs文件,则失败。如果我创建一个项目并修改其.cabal和.yaml,则它将起作用。我想也许与环境有关。这些软件包已下载但已隐藏。

所以我在这里的问题是:是否有任何解决方法可以让单个.hs文件(显然它既没有.cabal也没有.yaml)看到软件包?

0 个答案:

没有答案