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++.


Alex is part of the Haskell Platform, so if you install the platform you will automatically have a working Alex.

Alex is also on Hackage. If you have the cabal-install tool (which also comes with the Haskell Platform), then you can build and install the latest version of Alex with

        cabal install alex

To find out what the latest version of Alex is, and to download the source separately, go to Alex's HackageDB page.

Alex might also be pre-packaged for your OS:

  • 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, to get the latest version say:

   git clone

Feel free to hack on Alex and send me your merge requests or patches.

Simon Marlow <>