Is eta reduction possible?

后端 未结 4 892
囚心锁ツ
囚心锁ツ 2021-01-12 20:25

Is it possible to apply eta reduction in below case?

let normalise = filter (\\x -> Data.Char.isLetter x || Data.Char.isSpace x )

I was

4条回答
  •  情话喂你
    2021-01-12 21:06

    You could take advantage of the Any monoid and the monoid instance for functions returning monoid values:

    import Data.Monoid
    import Data.Char
    
    let normalise = filter (getAny . ((Any . isLetter) `mappend` (Any . isSpace)))
    

提交回复
热议问题