質問

Let say I have need to define the following function:

Identity = chr.ord

But the above line won't work, the correct way would be:

Identity = (chr.ord)

Haskell usually is quite a minimalist language, so using that extra brackets does not seem natural(to me).

Is anyone aware of the need for introducing the brackets. I can't remember where else we use the dot operator in haskell (other then for decimals).

Editing after comments from Nate/Daniel

Both you are correct. My actual method was:

nextLetter a 
         | a /= 'z' = chr.ord a
         | a == 'z' = 'a'

Now I understand, in this case it will evaluate ord a and then try to evaluate chr.97, hence the error!

Thanks.

役に立ちましたか?

解決

You're mistaken. When I write

import Data.Char
identity = chr.ord

in test.hs and load it in ghci, nothing goes wrong.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top