{-# LANGUAGE TypeOperators, DataKinds, PolyKinds, TypeFamilies, TypeInType,
RankNTypes, FlexibleContexts, TemplateHaskell,
UndecidableInstances, GADTs, DefaultSignatures #-}
module Data.Singletons.Prelude.Eq (
PEq(..), SEq(..),
type (==@#@$), type (==@#@$$), type (==@#@$$$),
type (/=@#@$), type (/=@#@$$), type (/=@#@$$$)
) where
import Data.Singletons.Prelude.Bool
import Data.Singletons.Single
import Data.Singletons.Prelude.Instances
import Data.Singletons.Util
import Data.Singletons.Promote
import qualified Data.Type.Equality as DTE
class PEq a where
type (==) (x :: a) (y :: a) :: Bool
type (/=) (x :: a) (y :: a) :: Bool
type (x :: a) == (y :: a) = x DTE.== y
type (x :: a) /= (y :: a) = Not (x == y)
infix 4 ==
infix 4 /=
$(genDefunSymbols [''(==), ''(/=)])
class SEq k where
(%==) :: forall (a :: k) (b :: k). Sing a -> Sing b -> Sing (a == b)
infix 4 %==
(%/=) :: forall (a :: k) (b :: k). Sing a -> Sing b -> Sing (a /= b)
default (%/=) :: forall (a :: k) (b :: k).
((a /= b) ~ Not (a == b))
=> Sing a -> Sing b -> Sing (a /= b)
a %/= b = sNot (a %== b)
infix 4 %/=
$(singEqInstances basicTypes)