Re: [Haskell-cafe] use of modules to save typing

From: Michael Mossey
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" John
participants (1)
-
John Lato