This modules provides a convienient way to access and update the elements of a structure.
It is very similar to Data.Accessors, but a bit more generic and has fewer dependencies.
I particularly like how cleanly it handles nested structures in state monads.
runSTLense is also a very useful function.

A brief tutorial to get started:

To create a lense, you can use fromGetSet (although usually you would just derive them using templat haskell and deriveLenses from Data.Lenses.Template):

lense = fromGetSet getField setField

The lense has type:

lense :: (MonadState r m) => StateT a m b -> m b

Where r is the type of the record, and a is the type of the field, (b can be any type you choose, more on that latter). Though it may help to think of it as:

lense :: State a b -> State r b

Which is not entirely accurate, but emphasises how the lense works.
You can think of it as "pass in an action that operates on the field, and you get an action that operates on the record".
So say we pass in get (with a more specific type for clarity):

get :: State a a
lense get :: State r a

We get out a state monad that we can run on our record to fetch our field.

To aid in clarity and to deal with the actual types of the lenses this module provides execIn, evalFrom, and runOn to be used in place of execState, evalState, and runState. Also note that execIn, evalFrom, and runOn have their parameters fliped from their state counterparts. There is nothing magical about these functions, they are just a little more handy than their state counterparts.

The lenses are especially convienient if you have nested structures. Lense composition is just function composition.

and nothing appears to be wrong with your code, try turning the restriction off with -XNoMonomorphismRestriction and see if it goes away.
If it does then you probably need to add some explicit type signatures somewhere.

I whipped out this documentation in a hurry, so if you spot any errors, or think I should explain something better, please let me know. This library is hosted on github (click on the Contents link above and you should see the Homepage link) so it should be very easy to forked it and send patches to me.
Also since this module is new I'm open to radical modifications if you have a good suggestion, so suggest away! :)

Structure lenses

This function has the magical ability to convert a function that fetches elements from a structure, to a function that lets you modify the elements in the structure.
The catch is that the structure must be a member of Traversable.

processedOriginalStructure has the same shape as originalStructure but every element has been replaced with a transformer function (State a b -> s).
specialFunction needs to return the result of the application of the functions in processedOriginalStructure to a state monad.
The state monad by definition will return a result and potentially update state. Getting state will get the value of the element in originalStructure.
Updating state will update the value of the element in updatedStructure. The returned values are gathered in collectedValues.