[Haskell-beginners] calling inpure functions from pure code

Emmanuel Touzery etouzery at gmail.com
Fri Oct 12 16:19:57 CEST 2012


Hello,

> Maybe you would feel better about it if you put both functions under one
> "umbrella" function like this:
>
>> parseProgramme = getDetails . getProgramme
>>    where
>>    getProgramme = ...
>>    getDetails = ...
> That way, your "incomplete" objects would never be exposed to "end user"
> (even though it's just you). It also gives you an abstraction that may
> gain you in a future when, say, you would want to fetch pictures as
> well — it would be just a matter of adding one more function under the
> "umbrella".
>
> Overall, splitting your algorithm into simple steps — steps that would
> do just a part of work and return incomplete objects — is the way to go.
>

You have a point, about splitting code for smaller functions. I would 
just rather have getDetails called from getProgramme rather than a 
parent calling both separately. And the parent must do the connection by 
doing the IO if I want both pieces to be pure. That is what is bothering 
me mostly.

Emmanuel



More information about the Beginners mailing list