Point Free problems in Haskell

前端 未结 3 1507
不知归路
不知归路 2020-12-02 16:23

I am trying to convert the following Haskell code to point free style, to no avail.

bar f g xs = filter f (map g xs )

I\'m new to Haskell a

3条回答
  •  日久生厌
    2020-12-02 16:49

    I asked lambdabot, a robot who hangs out on various Haskell IRC channels, to automatically work out the point-free equivalent. The command is @pl (pointless).

    10:41  @pl bar f g xs = filter f (map g xs )
    10:41  bar = (. map) . (.) . filter
    

    The point free version of bar is:

    bar = (. map) . (.) . filter
    

    This is arguably less comprehensible than the original (non-point-free) code. Use your good judgement when deciding whether to use point-free style on a case-by-case basis.

    Finally, if you don't care for IRC there are web-based point-free converters such as pointfree.io, the pointfree command line program, and other tools.

提交回复
热议问题