Error about “type signature with no binding”

后端 未结 2 674
予麋鹿
予麋鹿 2021-01-29 12:25

I have a problem with ASCII in Haskell.

fromEnum :: Char -> Int
toEnum :: Int -> Char

offset :: Int
offset = fromEnum \'A\' - fromEnum \'a\'

toUpper ::          


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 12:59

    Unless you are doing this as an exercise, you should really use toUpper from module Data.Char.

    Doing this well requires to check how uppercase is defined in Unicode -- I'd rather rely on the standard library for that :)

    Also, watch out because your toUpper is not idempotent: one might expect that toUpper 'A' == 'A', for instance.

提交回复
热议问题