[Haskell-beginners] general observation about programming

Henk-Jan van Tuyl hjgtuyl at chello.nl
Sun Feb 28 01:35:15 UTC 2016


On Sat, 27 Feb 2016 07:17:13 +0100, Rustom Mody <rustompmody at gmail.com>  
wrote:

> On Fri, Feb 26, 2016 at 11:11 PM, Rein Henrichs <rein.henrichs at gmail.com>
> wrote:
>
>> Pointfree is good for reasoning about *composition*. It can often be  
>> more
>> readable than pointful code when the focus of the function is on
>> composition of other functions. For example, take this function from  
>> Bird's *Pearls
>> of Functional Algorithm Design*:
>>
>>  boxes = map ungroup . ungroup . map cols . group . map group
>>
>
> And better if you read it in the right (ie left to right order)
>
>
> boxes  =  map group >>> group >>> map cols >> ungroup >>> map ungroup
> (From Control.Arrow)
>
> Even better if the 3-char clunky >>> is reduced to the 1-char ⋙
> map group ⋙ group ⋙ map cols ⋙ ungroup ⋙ map ungroup
> (From Control.Arrow.Unicode)

You can also use & from Data.Function (since base 4.8.0.0)
   map group & group & map cols & ungroup & map ungroup

Regards,
Henk-Jan van Tuyl


-- 
Folding at home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--


More information about the Beginners mailing list