0

Is it possible to make Level an instance of Eq and Ord?

instance Eq Ord Level where
    compare First Second = LT
    ...

I've tried this

instance (Ord, Eq) => Level where ...

But I've got an error

‘compare’ is not a (visible) method of class ‘Level’

I know I can use deriving (Eq) on my data Level. But I cannot change my data.

1 Answer 1

7

Use two instances

instance Eq Level where
   x == y = ...
instance Ord Level where
   compare x y = ...

Alternatively, use the standalone deriving extension:

{-# LANGUAGE StandaloneDeriving #-}
...       -- ^^^^^^^^^^^^^^^^^^ must be at the top of the file
deriving instance (Eq Level)
deriving instance (Ord Level)
Sign up to request clarification or add additional context in comments.

1 Comment

@chi, ah, missed it. Sorry.

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.