【问题标题】:How to resolve the issue "Can't find import Effects" in Idris?如何解决 Idris 中“找不到导入效果”的问题?
【发布时间】:2019-03-20 00:13:19
【问题描述】:

在离开 Idris 一段时间后,我试图使用 nix-shell 环境 (direction) 编译以下“hello world”源文件:

module Main

import Effects
import Effect.StdIO

hello : Eff () [STDIO]
hello = putStrLn "Hello world!"

main : IO ()
main = run hello

我在实验过程中的输出如下;尽管指定了似乎是正确的库,但最后我仍然收到相同的错误:

[nix-shell:~/workspace/idris_tmp]$ idris --listlibs
00prelude-idx.ibc
prelude
00base-idx.ibc
base

[nix-shell:~/workspace/idris_tmp]$ exit
exit
brandon@brandon-750-170se-DevContainer:~/workspace/idris_tmp
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib effects ])' -p closurecompiler
these derivations will be built:
  /nix/store/j44rkb0fpxqd4qkamrg1ysf9kbx1q2qa-idris-1.3.0.drv
these paths will be fetched (1.55 MiB download, 4.37 MiB unpacked):
  /nix/store/1fcldlyp5n0ry22dsqfam68mpra6jky9-idris-effects-1.3.0
  /nix/store/a9rjm84pbmvg6dmkdzhl9q1wliyi0q4b-idris-contrib-1.3.0
copying path '/nix/store/a9rjm84pbmvg6dmkdzhl9q1wliyi0q4b-idris-contrib-1.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/1fcldlyp5n0ry22dsqfam68mpra6jky9-idris-effects-1.3.0' from 'https://cache.nixos.org'...
building '/nix/store/j44rkb0fpxqd4qkamrg1ysf9kbx1q2qa-idris-1.3.0.drv'...
/nix/store/5dny6qnjfq9liya5z1sxvr2g64bqypwl-idris-base-1.3.0/nix-support:
propagated-build-inputs: /nix/store/1fcldlyp5n0ry22dsqfam68mpra6jky9-idris-effects-1.3.0/nix-support/propagated-build-inputs
/nix/store/a9rjm84pbmvg6dmkdzhl9q1wliyi0q4b-idris-contrib-1.3.0/nix-support:
propagated-build-inputs: /nix/store/1fcldlyp5n0ry22dsqfam68mpra6jky9-idris-effects-1.3.0/nix-support/propagated-build-inputs
/nix/store/a5x52wi84jgjiimpnkfpcl3mbpbkf1r4-idris-1.3.0/nix-support:
propagated-build-inputs: /nix/store/1fcldlyp5n0ry22dsqfam68mpra6jky9-idris-effects-1.3.0/nix-support/propagated-build-inputs


[nix-shell:~/workspace/idris_tmp]$ idris --listlibs
00effects-idx.ibc
effects
00base-idx.ibc
base
00prelude-idx.ibc
prelude
00contrib-idx.ibc
contrib

[nix-shell:~/workspace/idris_tmp]$ idris --codegen javascript hello.idr -o hello.js
 Can't find import Effects

【问题讨论】:

    标签: idris nix


    【解决方案1】:

    尝试将-p effects 添加到您的命令行中

    idris -p effects --codegen javascript hello.idr -o hello.js
    

    这将加载额外的库/包。您可以通过定义一个描述您的构建的 ipkg 文件来避免这样做。见这里:http://docs.idris-lang.org/en/latest/reference/packages.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 1970-01-01
      • 1970-01-01
      • 2023-02-23
      相关资源
      最近更新 更多