Search code examples
haskellcabalcabal-installhappyalex

Did I install cabal correctly?


Hi I've just updated cabal to the latest version by the command

cabal update

and

cabal install cabal-install

Then it returns

Installed cabal-install-1.22.2.0
Updating documentation index /MyPath

I want to use alex and happy. Sorry I'm very new to it.. When I tried to issue alex in ghci by the line

alex wordcount.x

It returns

Not in scope: ‘alex’
Perhaps you meant ‘lex’ (imported from Prelude)

I searched online for this and I found a webpage saying that I should first check the version of them by

 cabal configure -v | grep -e alex -e happy

But I got this line

cabal: No cabal file found.
Please create a package description file <pkgname>.cabal

Could anyone help me with this problem?


Solution

  • Once you install cabal you can install other packages.

    So, to install the Alex package, you'll do cabal install alex. Then I see that you tried to invoke Alex in GHCi, but that's not correct, since alex is a program. You have to invoke it from the terminal.