Partial application of operators

前端 未结 2 1432
傲寒
傲寒 2021-01-17 02:50

If I want to add a space at the end of a character to return a list, how would I accomplish this with partial application if I am passing no arguments?

Also would th

2条回答
  •  不思量自难忘°
    2021-01-17 02:53

    What you want here is an operator section. For that, you'll need to surround the application with parentheses, i.e.

    space = (: " ")
    

    which is syntactic sugar for

    space = (\x -> x : " ")
    

    (++) won't work here because it expects a string as the first argument, compare:

    (:)  :: a -> [a] -> [a]
    (++) :: [a] -> [a] -> [a]
    

提交回复
热议问题