This is a slightly confusing question, as "I want to check" hints that you might want to find this out dynamically.
Haskell will check all types at compile time, including membership of typeclasses. So to check if a literal is of a type that supports Eq, you simply need to use it with (==)
or (/=)
and try to compile it.
If you are just exploring which types have Eq instances, check the :info
command in GHCi:
Prelude> let x = 1
Prelude> :info x
x :: Integer -- Defined at <interactive>:1:5
Prelude> :info Integer
data Integer
= integer-gmp:GHC.Integer.Type.S# GHC.Prim.Int#
| integer-gmp:GHC.Integer.Type.J# GHC.Prim.Int# GHC.Prim.ByteArray#
-- Defined in integer-gmp:GHC.Integer.Type
instance Enum Integer -- Defined in GHC.Num
instance Eq Integer -- Defined in GHC.Classes
instance Integral Integer -- Defined in GHC.Real
instance Num Integer -- Defined in GHC.Num
instance Ord Integer -- Defined in GHC.Classes
instance Read Integer -- Defined in GHC.Read
instance Real Integer -- Defined in GHC.Real
Prelude> :info Eq
class Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool
-- Defined in GHC.Classes
instance Eq a => Eq (Maybe a) -- Defined in Data.Maybe