Why GHC avoids tacit programming?

317 Views Asked by At

I was looking at GHC.Unicode library source and realized that almost all the Haskell internal libraries avoid tacit programming (aka point-free style) most of the time. Simple functions can be easily converted, such as:

isLatin1 :: Char -> Bool
isLatin1 c = c <= '\xff'

Resulting in:

isLatin1 :: Char -> Bool
isLatin1 = (<= '\xff')

But there are cases where I can't apply it, such as when I have more complex functions, like:

isOctDigit c =  c >= '0' && c <= '7'

Is hard to deduct a way to compose the operations. I don't mean to get in the range, I mean to do multiple operations just by composing functions. The following:

isOctDigit = (>= '0') && (<= '7')

Is not valid, and also (>= '0') . (<= '7') clearly cannot happen because of the different return types.

Taking account these observations, I have the following questions:

  • When should I use point-free programming instead of explicit it all?
  • Why GHC prefer to explicit instead of use partial functions?
  • How can I compose two functions of different types without being explicit, such as in the example?
0

There are 0 best solutions below