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.
$ cabal install alex
$ stack install alex
Moreover, recent versions of
cabal will automatically install the required version of
alex based on
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.