Obtaining Alex

If you just want to use Alex, you can build from a release. This should work the same as any other Haskell package.

Alex itself and its examples are intended to work with GHC >= 7.0.

Haskell-specific way

From Hackage via Cabal Install:

$ cabal install alex

From Stackage via Stack:

$ stack install alex

Moreover, recent versions of cabal will automatically install the required version of alex based on build-tools/build-tool-depends declarations.

Operating System way

Because Alex is a dependency of GHC, it is often packaged by operating systems. Repology aggregates this info across many distros and operating systems, and Alex is actually listed twice:

The table contains links to the individual OS packages, which should provide installation instructions.