[Haskell-beginners] Re: Is this overkill?

Chaddaï Fouché chaddai.fouche at gmail.com
Sun Apr 5 11:57:13 EDT 2009


On Sat, Apr 4, 2009 at 5:20 AM, Zachary Turner <divisortheory at gmail.com> wrote:
>> With Conal's semantic editor combinators
>>
>>  http://conal.net/blog/posts/semantic-editor-combinators/
>>
>> it would be written as
>>
>>  trueIndices =
>>    (result . result) (map fst . filter snd . zip [0..]) (zipWith (&&))
>
>
> That was a pretty interesting blog post, and easily understandable which is
> always nice.  Thanks for the link.  I also had never even used the zipWith
> function, so thanks for pointing out that equivalence.

I'm not sure you really want to write this pointfree... Generally I
tend to avoid it when there's two arguments of identical standing.
Also the (map fst . filter snd...) is a Data.List function
(findIndices) :

trueIndices xs ys = findindices id $ zipWith (&&) xs ys

I love the pointfree style and it might be a good exercise to try and
transcribe any function to pointfree, but sometimes pointful is just
clearer.

-- 
Jedaï


More information about the Beginners mailing list