{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
module PlutusTx.Eq (Eq(..), (/=)) where
import PlutusTx.Bool
import PlutusTx.Builtins qualified as Builtins
import PlutusTx.Either (Either (..))
import Prelude (Maybe (..))
infix 4 ==, /=
class Eq a where
(==) :: a -> a -> Bool
{-# INLINABLE (/=) #-}
(/=) :: Eq a => a -> a -> Bool
a
x /= :: a -> a -> Bool
/= a
y = Bool -> Bool
not (a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
y)
instance Eq Builtins.Integer where
{-# INLINABLE (==) #-}
== :: Integer -> Integer -> Bool
(==) = Integer -> Integer -> Bool
Builtins.equalsInteger
instance Eq Builtins.BuiltinByteString where
{-# INLINABLE (==) #-}
== :: BuiltinByteString -> BuiltinByteString -> Bool
(==) = BuiltinByteString -> BuiltinByteString -> Bool
Builtins.equalsByteString
instance Eq Builtins.BuiltinData where
{-# INLINABLE (==) #-}
== :: BuiltinData -> BuiltinData -> Bool
(==) = BuiltinData -> BuiltinData -> Bool
Builtins.equalsData
instance Eq Builtins.BuiltinString where
{-# INLINABLE (==) #-}
== :: BuiltinString -> BuiltinString -> Bool
(==) = BuiltinString -> BuiltinString -> Bool
Builtins.equalsString
instance Eq a => Eq [a] where
{-# INLINABLE (==) #-}
[] == :: [a] -> [a] -> Bool
== [] = Bool
True
(a
x:[a]
xs) == (a
y:[a]
ys) = a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
y Bool -> Bool -> Bool
&& [a]
xs [a] -> [a] -> Bool
forall a. Eq a => a -> a -> Bool
== [a]
ys
[a]
_ == [a]
_ = Bool
False
instance Eq Bool where
{-# INLINABLE (==) #-}
Bool
True == :: Bool -> Bool -> Bool
== Bool
True = Bool
True
Bool
False == Bool
False = Bool
True
Bool
_ == Bool
_ = Bool
False
instance Eq a => Eq (Maybe a) where
{-# INLINABLE (==) #-}
(Just a
a1) == :: Maybe a -> Maybe a -> Bool
== (Just a
a2) = a
a1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a2
Maybe a
Nothing == Maybe a
Nothing = Bool
True
Maybe a
_ == Maybe a
_ = Bool
False
instance (Eq a, Eq b) => Eq (Either a b) where
{-# INLINABLE (==) #-}
(Left a
a1) == :: Either a b -> Either a b -> Bool
== (Left a
a2) = a
a1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a2
(Right b
b1) == (Right b
b2) = b
b1 b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== b
b2
Either a b
_ == Either a b
_ = Bool
False
instance Eq () where
{-# INLINABLE (==) #-}
()
_ == :: () -> () -> Bool
== ()
_ = Bool
True
instance (Eq a, Eq b) => Eq (a, b) where
{-# INLINABLE (==) #-}
(a
a, b
b) == :: (a, b) -> (a, b) -> Bool
== (a
a', b
b') = a
a a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a' Bool -> Bool -> Bool
&& b
b b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== b
b'