[Haskell-beginners] Looking for alternative practices suggestions

Brent Yorgey byorgey at seas.upenn.edu
Fri Aug 5 15:51:28 CEST 2011


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



More information about the Beginners mailing list