如何在Haskell平台上安装Alex?

如何在Haskell平台上安装Alex?,haskell,alex,Haskell,Alex,我在Windows上安装了Haskell Platform 8.2.2。当我运行ghci并在Prelude>之后键入alex H.x时,我得到 <interactive>:3:6: error: Not in scope: `H.x' No module named `H' is imported. <interactive>:6:1: error: * Variable not in scope: alex * Perhaps you

我在Windows上安装了Haskell Platform 8.2.2。当我运行
ghci
并在
Prelude>之后键入
alex H.x
时,我得到

<interactive>:3:6: error:
    Not in scope: `H.x'
    No module named `H' is imported.
<interactive>:6:1: error:
    * Variable not in scope: alex
    * Perhaps you meant `lex' (imported from Prelude).
我在
Haskell Platform\8.2.2\lib
中查看了一个名为
Cabal-2.0.1.0
的文件夹,但没有找到
alex


如何安装Alex?

Alex
是一个可执行程序,从命令行运行,而不是从GHCi调用的库

要通过
stack
运行
alex
(这是您安装的),请键入:

(假设您实际上有一个名为
H.x
的文件)

第一次这样运行时,
stack
将构建
alex
,这将需要几分钟的时间。这只会发生一次,后续运行会很快

如果要在不使用
stack
的情况下运行
alex
,可以要求
stack
alex
放在
路径上。为此,请键入:

stack install alex
在这之后,您可以执行
alex
,而无需每次预加
stack exec

alex H.x
alex H.x