Alex: A lexical analyser generator for Haskell

Alex is a tool for generating lexical analysers in Haskell, given a description of the tokens to be recognised in the form of regular expressions. It is similar to the tool lex or flex for C/C++.


Documentation is hosted on Read the Docs.


From Hackage via cabal-install:

        cabal install alex

From Stackage via stack, e.g.:

        stack install --resolver nightly alex

Alex might also be pre-packaged for your OS (unconfirmed as of 2022-04-06):

  • Ubuntu users: packages should be available from the universe repository.
  • Debian GNU/Linux users: packages are available here.
  • RPMs for other versions of Linux can be built directly from the source, using rpmbuild -ta.
  • FreeBSD/x86 users: Alex is in the ports tree, so either pkg_add -r hs-alex, or install it from the ports tree in /usr/ports/devel/hs-alex.
  • OpenBSD users: Alex is in the -current ports tree, you can install it from /usr/ports/devel/alex.

Alex is licensed under a BSD-style license. The current sources are on github, get the latest version with:

   git clone

Contribute by opening issues which can be followed up by pull requests.

Source of this page: index.html, deployed 2022-04-06.