
Thanks Brent. I just may use a Reader monad in version 2 for the sake
of learning how to do it.
On Fri, Aug 5, 2011 at 6:51 AM, Brent Yorgey
On Thu, Aug 04, 2011 at 02:53:34PM -0700, Michael Litchard wrote:
I'm finding that in more than one instance I pass a data structure to a function, simply so that I can pass it to it's helper function. It bugs me that I'm passing a value that isn't being used directly. This seems wrong. Example: I have a "data URLSequence" that contains a way to calculate the ip address of a URL. This gets passed to a helper function that generates a particular URL, which then populates the URLSequence. Is there a standard practice to avoid what I am talking about? Or is this normal and I should accept it?
Others have answered the question in a way that seems to address your situation well. However, I thought I would also mention that in the case where there is a single piece of read-only data that needs to be annoyingly threaded through large parts of your code, you can use the Reader monad to make the threading implicit. But this solution is too heavyweight for some situations since it does require changing the code to use a monadic style.
-Brent
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners