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
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
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
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
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
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
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
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
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: