I have to dessignate types of 2 functions(without using compiler :t) i just dont know how soudl i read these functions to make correct steps.
f x = map -1 x
f x = map (-1) x
Well i’m a bit confuse how it will be parsed
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Function application, or “the empty space operator” has higher precedence than any operator symbol, so the first line parses as
f x = map - (1 x), which will most likely1 be a type error.The other example is parenthesized the way it looks, but note that
(-1)desugars asnegate 1. This is an exception from the normal rule, where operator sections like(+1)desugar as(\x -> x + 1), so this will also likely1 be a type error sincemapexpects a function, not a number, as its first argument.1 I say likely because it is technically possible to provide
Numinstances for functions which may allow this to type check.