我收到此错误:
aff.hs:3:8:
Could not find module ‘Control.Lens’
Perhaps you haven't installed the "js" libraries for package ‘lens-4.7’?
Use -v to see a list of the files searched for.
用ghcjs aff.hs编译这个文件时:
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Foo = Foo { _x :: Int, _y :: Int } deriving Show
makeLenses ''Foo
main = do
let foo = Foo 1 2
print (foo & x .~ 7)
ghcjs aff.hs -v出错:
vh:hs apple1$ghcjs aff.hs -v
Glasgow Haskell Compiler for JavaScript, Version 7.8.4, stage 2 booted by GHC version 7.8.3
Using binary package database: /Users/apple1/.ghcjs/x86_64-darwin-0.1.0-7.8.4/ghcjs/package.conf.d/package.cache
Using binary package database: /Users/apple1/.ghcjs/x86_64-darwin-0.1.0-7.8.4/package.conf.d/package.cache
hiding package GLUT-2.5.1.1 to avoid conflict with later version GLUT-2.6.0.0
hiding package OpenGL-2.9.2.0 to avoid conflict with later version OpenGL-2.10.0.0
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-6e5df05b8d31294b1553cc2e7f7972db
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-c643540c959b8d4136c733c4ecf986b3
wired-in package base mapped to base-4.7.0.2-a962de1f083bee8a0176a548387263c2
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-3231d71f33d4fa4ea3f0278ff8020078
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
hiding package GLUT-2.5.1.1 to avoid conflict with later version GLUT-2.6.0.0
hiding package OpenGL-2.9.2.0 to avoid conflict with later version OpenGL-2.10.0.0
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-6e5df05b8d31294b1553cc2e7f7972db
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-c643540c959b8d4136c733c4ecf986b3
wired-in package base mapped to base-4.7.0.2-a962de1f083bee8a0176a548387263c2
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-3231d71f33d4fa4ea3f0278ff8020078
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *aff.hs
aff.hs:3:8:
Could not find module ‘Control.Lens’
Perhaps you haven't installed the "js" libraries for package ‘lens-4.7’?
Locations searched:
Control/Lens.hs
Control/Lens.lhs
/Users/apple1/.cabal/lib/x86_64-osx-ghcjs-0.1.0-ghc7_8_4/lens-4.7/Control/Lens.js_hi
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
该文件位于沙盒目录中.我安装了带有cabal安装的镜头–ghcjs镜头.好像它已正确安装:
vh:hs apple1$ghcjs-pkg list
/Users/apple1/.ghcjs/x86_64-darwin-0.1.0-7.8.4/ghcjs/package.conf.d
Cabal-1.22.0.0
aeson-0.8.0.2
array-0.5.0.0
async-2.0.1.6
attoparsec-0.12.1.2
base-4.7.0.2
binary-0.7.2.3
bytestring-0.10.6.0
case-insensitive-1.2.0.3
containers-0.5.6.2
deepseq-1.3.0.2
directory-1.2.1.0
dlist-0.7.1
extensible-exceptions-0.1.1.3
filepath-1.3.0.2
ghc-prim-0.3.1.0
ghcjs-base-0.1.0.0
ghcjs-prim-0.1.0.0
hashable-1.2.3.1
integer-gmp-0.5.1.0
mtl-2.2.1
old-locale-1.0.0.6
old-time-1.1.0.2
parallel-3.2.0.4
pretty-1.1.2.0
primitive-0.5.4.0
process-1.2.0.0
rts-1.0
scientific-0.3.3.3
stm-2.4.3
syb-0.4.4
template-haskell-2.9.0.0
text-1.2.0.3
time-1.4.2
transformers-0.4.2.0
unix-2.7.0.1
unordered-containers-0.2.5.1
vector-0.10.12.2
/Users/apple1/.ghcjs/x86_64-darwin-0.1.0-7.8.4/package.conf.d
GLURaw-1.4.0.2
GLUT-2.5.1.1
GLUT-2.6.0.0
OpenGL-2.9.2.0
OpenGL-2.10.0.0
OpenGLRaw-1.5.0.1
QuickCheck-2.7.6
adjunctions-4.2
bifunctors-4.2
bmp-1.2.5.2
comonad-4.2.2
contravariant-1.2.0.1
distributive-0.4.4
exceptions-0.6.1
free-4.10.0.1
ghcjs-dom-0.1.1.3
gloss-1.9.2.1
gloss-raster-1.9.2.1
gloss-rendering-1.9.2.1
hashmap-1.3.0.1
lens-4.7
linear-1.16
nats-1
prelude-extras-0.4
profunctors-4.3.2
random-1.1
reflection-1.5.1
repa-3.3.1.2
semigroupoids-4.2
semigroups-0.16.0.1
sodium-0.11.0.3
split-0.2.2
tagged-0.7.3
tf-random-0.5
transformers-compat-0.3.3.4
void-0.7
最佳答案 我这样做:
编辑cabal.sandbox.config以使package-db:line指向沙箱的ghcjs子目录.它看起来应该像package-db:/path-to-project/.cabal-sandbox/x86_64-linux-ghcjs-0.1.0-ghc7_8_4-packages.conf.d
然后运行cabal sandbox hc-pkg list.