0

I keep getting this message, what am I doing wrong?

quadrant :: Float -> Float -> Quadrant
quadrant x y
    |x = 0 && y = 0 = Origin
    |x > 0 && y = 0 = X_ Axis_Positive
    |x > 0 && y > 0 = Quadrant_1
    |x = 0 && y > 0 = Y_ Axis_Positive
    |x < 0 && y > 0 = Quadrant_2
    |x < 0 && y = 0 = X_ Axis_Negative
    |x < 0 && y < 0 = Quadrant_3
    |x = 0 && y < 0 = Y_ Axis_Negative
    |x > 0 && y < 0 = Quadrant_4
    |otherwise = error "Program error: Non-Exhaustive guards in function: quadrant"

1 Answer 1

7

The operator to test for equality is ==, where = is part of the language grammar.

Sign up to request clarification or add additional context in comments.

4 Comments

(==) isn't part of the language syntax but part of the Prelude. It's defined with infix 4 ==; (==) :: (Eq a) => a -> a -> Bool
I'm not disagreeing with the fundamental answer - but I was hoping for refinement on the last few words, and possibly a reference (e.g. as to "what" = is).
Semantics. It's probably more accurate to say grammar. I'm referring to the rules of the language structure, and not the whole language itself.
@user2864740 (==) is a type class method that is defined in the Haskell standard library and = is a fundamental part of the Haskell language itself. = cannot be broken down further, in the same sense as { and } in C/C++/C#/Java/etc and : in Python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.