Я установил Yampa, но мне не удалось импортировать FRP. Yampa (Ma c OS Catalina) - PullRequest
3 голосов
/ 02 мая 2020

Я недавно прочитал о 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

Я не сдался и использовал "gh c -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 ----------------------------------- -------------

Файл был создан напрямую (без использования «стек нового»). Это означает, что я просто создаю текстовый файл, помещаю строку «import FRP.Yampa» и меняю его имя на helloworld.hs в папке «haskell_code» в VScode.

Однако, если я использую «stack new mysti c "для создания проекта под названием mysti c. и go на его 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

Поэтому я изменил файл mysti c .cabal, добавив Yampa к его зависимости от сборки (я не использовал ' : 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)

И я воспользовался его советом, добавив строку к deps of stack.yaml

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

Работает. Также я попробовал некоторые другие пакеты. Если я создаю один файл .hs, у меня не получается. Если я создаю проект и изменяю его .cabal и .yaml, он работает. Наверное, это как-то связано с окружающей средой. Эти пакеты загружены, но скрыты.

Итак, мой вопрос здесь: есть ли обходной путь, позволяющий увидеть пакеты даже в одном файле .hs (очевидно, он не имеет ни .cabal, ни .yaml)?

...