-1

I have Haskell Platform 8.2.2 installed on Windows. When I run ghci and type alex H.x after Prelude>, I get

<interactive>:3:6: error:
    Not in scope: `H.x'
    No module named `H' is imported.

When I type just alex, I get

<interactive>:6:1: error:
    * Variable not in scope: alex
    * Perhaps you meant `lex' (imported from Prelude).

I looked in Haskell Platform\8.2.2\lib and I can see a folder called Cabal-2.0.1.0 but nothing for alex.

How do I get Alex installed?

johnsmith
  • 515
  • 5
  • 12

1 Answers1

2

alex is an executable program, to be run from command line, not a library to be invoked from GHCi.

To run alex via stack (which is what you have installed), type:

stack exec alex H.x

(assuming you actually have a file named H.x lying around)

The first time you run it like this, stack will build alex, which will take a few minutes. This will happen one time only, subsequent runs will be quick.

If you want to run alex without stack, you can ask stack to put alex on your PATH. To do that, type:

stack install alex

After that, you can execute alex without prepending stack exec every time:

alex H.x
Fyodor Soikin
  • 78,590
  • 9
  • 125
  • 172