Alex/Wrapper monadUser

From HaskellWiki
< Alex
Revision as of 19:13, 1 February 2007 by BrettGiles (talk | contribs) (Add notes for wrapper for alex)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The file

Download the code: media:AlexWrapper-monadUser

Note this is only a minor change to the current monad wrapper.

Usage

In the Alex source file

In Alex, wrappers are chosen by the %wrapper directive. To use the monadUser wrapper, add the line

    %wrapper "monadUser"

after the initial code block in your Alex source file.

Additionally, two items must be defined in a code block (or imported), the Haskell type UserData and the variable userStartState which must be of type UserData.

Where to put the wrapper source file

Alex retrieves wrappers from its template directory, typically /usr/lib/alex2.x.x. If you have access to that directory, simply place the file in there.

If not, create a directory named alex in your home directory. Copy all of the files from /usr/lib/alex2.x.x to alex. Then place the downloaded file in that directory.

Then, when running Alex, use the command:

   alex -t ~/alex input.x

which will tell alex to use the new directory for its templates.

Examples of use

To be done once the UofCalgary 411 class is done their first assignment :) BrettGiles