[Haskell-cafe] use of modules to save typing

John Lato jwlato at gmail.com
Thu Jul 8 08:11:27 EDT 2010

> From: Michael Mossey <mpm at alumni.caltech.edu>
> Now my monad looks like
> testMonad = do
>   cursor <- gets PlayState.cursor
>   len    <- gets PlayState.len
>   let newCur = min (cur+1) (len-1)
>   modify $ PlayState.update_cursor newCur
> Now I can define an abbreviation for PlayState. This is a big help.
> Also, I find this more readable. To me
>    PlayState.cursor
> is more readable than
>    playState_cursor
> For one thing, syntax highlighting helps in the former case. For
> another, the latter case requires that you recognize a naming
> convention, but the former case says clearly: "cursor is within the
> namespace PlayState, so this combination must be describing a cursor
> related to PlayState."

I do this as well, although I would probably import like this:

import qualified PlayState as PS

which then allows for "PS.cursor"


More information about the Haskell-Cafe mailing list