<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">On Fri, Jul 8, 2016 at 9:57 PM, Guru Devanla <span dir="ltr"><<a href="mailto:gurudev.devanla@gmail.com" target="_blank">gurudev.devanla@gmail.com</a>></span> wrote:</span></font></div></div></blockquote></div><div><br></div><div><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">1.  I see that almost in every function I deal with state, I have e <- get , expression in the begining. I always ending up having to use the state to query for different values. I guess this is OK.</span></font></div></blockquote></div></div></blockquote></div><div><br>El 8 jul 2016, a las 22:07, William Yager <<a href="mailto:will.yager@gmail.com">will.yager@gmail.com</a>> escribió:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>For #1, look into using the Lens library's support for the State monad. You can often avoid doing a get, and instead write things like `fees += 5`, which will add 5 to the field in the state called "fees".</div><div><br></div></div></div></blockquote><div><br></div><div>Lens is a pretty heavy extra thing for a beginner to have to learn -- you'll do fine with the 'modify' function:</div><div><br></div><div>modify :: (s -> s) -> State s ()</div><div><br></div><div>So instead of writing:</div><div><br></div><div>do</div><div>   s <- get</div><div>   put (s + 5)</div><div><br></div><div>You say:</div><div><br></div><div>modify (+5)</div><div><br></div><div><br></div><div>Tom</div></body></html>