[Haskell-cafe] use of modules to save typing

2010-07-08 Thread Michael Mossey
I'm fairly beginnerish to Haskell, and come from OO. I have a complaint about Haskell, but I think I found a good solution. Any suggestions welcome. I have RSI and like to minimize typing. The use of classes as name spaces helps to do that. Also I can use some Emacs abbreviation magic easily

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

2010-07-08 Thread Michael Mossey
Michael Mossey wrote: incrCursor :: State PlayState () incrCursor = cur - gets playState_cursor len - gets playState_len let newCur = min (cur+1) (len-1) modify (playState_update_cursor newCur) Whoa, I just realized I'm not using 'modify' to full advantage. This can be written

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

2010-07-08 Thread Tillmann Rendel
Michael Mossey wrote: incrCursor :: State PlayState () Additional question: what is proper terminology here? Proper terminology for monadic things is somewhat debated. incrCursor is a monad This is not true. incrCursor is a monadic type incrCursor is not a type, so this can't be

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

2010-07-08 Thread Neil Brown
On 08/07/10 09:08, Michael Mossey wrote: data PlayState = PlayState { playState_cursor :: Int , playState_verts :: [Loc] , playState_len :: Int , playState_doc :: MusDoc } Notice how often the characters

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

2010-07-08 Thread Michael Mossey
Neil Brown wrote: On 08/07/10 09:08, Michael Mossey wrote: data PlayState = PlayState { playState_cursor :: Int , playState_verts :: [Loc] , playState_len :: Int , playState_doc :: MusDoc } Notice how often

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

2010-07-08 Thread John Lato
From: Michael Mossey m...@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

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

2010-07-08 Thread Job Vranish
For working with record fields inside of state monads I would recommend trying out one of these packages: lenses fclabels data-accessor (I think I'm forgetting a couple) They all have special mechanisms for working with record fields inside state monads (and have lots of other cool stuff) I'm

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

2010-07-08 Thread Stephen Tetley
Hello all For manipulating records I use an arity family of so-called Starling combinators - they seem a pleasant if low-powered solution. To me, the infix combinator style of Data-Accessor quickly ends up looking like a particulary angry exchange between Snoopy and Woodstock[1]. star :: (a

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

2010-07-08 Thread Nils
On 08.07.2010 11:15, Michael Mossey wrote: Whoa, I just realized I'm not using 'modify' to full advantage. This can be written incrCursor = modify incrCursor' incrCursor' (PlayState cursor len verts doc) = PlayState (min (cursor+1)(len - 1)) len verts doc) Thats what lambdas are good for: