Copyright | (C) 2013 Richard Eisenberg |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- class PEq a where
- class SEq a where
- type family DefaultEq (a :: k) (b :: k) :: Bool where ...
- data (==@#@$) :: (~>) a ((~>) a Bool)
- data (==@#@$$) (a6989586621679140205 :: a) :: (~>) a Bool
- type family (a6989586621679140205 :: a) ==@#@$$$ (a6989586621679140206 :: a) :: Bool where ...
- data (/=@#@$) :: (~>) a ((~>) a Bool)
- data (/=@#@$$) (a6989586621679140210 :: a) :: (~>) a Bool
- type family (a6989586621679140210 :: a) /=@#@$$$ (a6989586621679140211 :: a) :: Bool where ...
- data DefaultEqSym0 :: (~>) k ((~>) k Bool)
- data DefaultEqSym1 (a6989586621679142401 :: k) :: (~>) k Bool
- type family DefaultEqSym2 (a6989586621679142401 :: k) (a6989586621679142402 :: k) :: Bool where ...
Documentation
type (arg :: a) == (arg :: a) :: Bool infix 4 Source #
type a == a = Apply (Apply TFHelper_6989586621679140225Sym0 a) a
type (arg :: a) /= (arg :: a) :: Bool infix 4 Source #
type a /= a = Apply (Apply TFHelper_6989586621679140214Sym0 a) a
Instances
PEq All Source # | |
PEq Any Source # | |
PEq Void Source # | |
PEq Ordering Source # | |
PEq Natural Source # | |
PEq () Source # | |
PEq Bool Source # | |
PEq Char Source # | |
PEq Symbol Source # | |
PEq (Identity a) Source # | |
PEq (First a) Source # | |
PEq (Last a) Source # | |
PEq (Down a) Source # | |
PEq (First a) Source # | |
PEq (Last a) Source # | |
PEq (Max a) Source # | |
PEq (Min a) Source # | |
PEq (WrappedMonoid m) Source # | |
PEq (Dual a) Source # | |
PEq (Product a) Source # | |
PEq (Sum a) Source # | |
PEq (NonEmpty a) Source # | |
PEq (Maybe a) Source # | |
PEq (TYPE rep) Source # | |
PEq [a] Source # | |
PEq (Either a b) Source # | |
PEq (Proxy s) Source # | |
PEq (Arg a b) Source # | |
PEq (a, b) Source # | |
PEq (Const a b) Source # | |
PEq (a, b, c) Source # | |
PEq (a, b, c, d) Source # | |
PEq (a, b, c, d, e) Source # | |
PEq (a, b, c, d, e, f) Source # | |
PEq (a, b, c, d, e, f, g) Source # | |
Nothing
(%==) :: forall (t :: a) (t :: a). Sing t -> Sing t -> Sing (Apply (Apply (==@#@$) t) t :: Bool) infix 4 Source #
default (%==) :: forall (t :: a) (t :: a). (Apply (Apply (==@#@$) t) t :: Bool) ~ Apply (Apply TFHelper_6989586621679140225Sym0 t) t => Sing t -> Sing t -> Sing (Apply (Apply (==@#@$) t) t :: Bool) Source #
(%/=) :: forall (t :: a) (t :: a). Sing t -> Sing t -> Sing (Apply (Apply (/=@#@$) t) t :: Bool) infix 4 Source #
Instances
type family DefaultEq (a :: k) (b :: k) :: Bool where ... Source #
One way to compute Boolean equality for types of any kind. This will
return True
if the two arguments are known to be the same type and False
if they are known to be apart. Examples:
>>>DefaultEq
Nothing
Nothing
True
>>>DefaultEq
Nothing
(Just
a)False
>>>DefaultEq
a aTrue
DefaultEq
is most suited for data types that are not inductively defined.
Four concrete examples of this are Natural
, Symbol
, Char
, and
Type
. One cannot implement boolean equality for these types by
pattern matching alone, so DefaultEq
is a good fit instead.
The downside to DefaultEq
is that it can fail to reduce if it is unable
to determine if two types are equal or apart. Here is one such example:
DefaultEq
(Just
a) (Just
b)
What should this reduce to? It depends on what a
and b
are. DefaultEq
has no way of knowing what these two types are, and as a result, this type
will be stuck. This is a pitfall that you can run into if you use
DefaultEq
to implement boolean equality for an inductive data type like
Maybe
. For this reason, it is usually recommended to implement boolean
equality for inductive data types using pattern matching and recursion, not
DefaultEq
.
Note that this definition is slightly different from the (==)
type
family from Data.Type.Equality in base
, as (==)
attempts to
distinguish applications of type constructors from other types. As a result,
a == a
does not reduce to True
for every a
, but
does reduce to DefaultEq
a aTrue
for every a
. The latter behavior is more desirable
for singletons
' purposes, so we use it instead of (==)
.
Defunctionalization symbols
data (==@#@$) :: (~>) a ((~>) a Bool) infix 4 Source #
Instances
SEq a => SingI ((==@#@$) :: TyFun a (a ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((==@#@$) :: TyFun a (a ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply ((==@#@$) :: TyFun a (a ~> Bool) -> Type) (a6989586621679140205 :: a) Source # | |
Defined in Data.Eq.Singletons |
data (==@#@$$) (a6989586621679140205 :: a) :: (~>) a Bool infix 4 Source #
Instances
SEq a => SingI1 ((==@#@$$) :: a -> TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
(SEq a, SingI d) => SingI ((==@#@$$) d :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((==@#@$$) a6989586621679140205 :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply ((==@#@$$) a6989586621679140205 :: TyFun a Bool -> Type) (a6989586621679140206 :: a) Source # | |
Defined in Data.Eq.Singletons |
type family (a6989586621679140205 :: a) ==@#@$$$ (a6989586621679140206 :: a) :: Bool where ... infix 4 Source #
data (/=@#@$) :: (~>) a ((~>) a Bool) infix 4 Source #
Instances
SEq a => SingI ((/=@#@$) :: TyFun a (a ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((/=@#@$) :: TyFun a (a ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply ((/=@#@$) :: TyFun a (a ~> Bool) -> Type) (a6989586621679140210 :: a) Source # | |
Defined in Data.Eq.Singletons |
data (/=@#@$$) (a6989586621679140210 :: a) :: (~>) a Bool infix 4 Source #
Instances
SEq a => SingI1 ((/=@#@$$) :: a -> TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
(SEq a, SingI d) => SingI ((/=@#@$$) d :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((/=@#@$$) a6989586621679140210 :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply ((/=@#@$$) a6989586621679140210 :: TyFun a Bool -> Type) (a6989586621679140211 :: a) Source # | |
Defined in Data.Eq.Singletons |
type family (a6989586621679140210 :: a) /=@#@$$$ (a6989586621679140211 :: a) :: Bool where ... infix 4 Source #
data DefaultEqSym0 :: (~>) k ((~>) k Bool) Source #
Instances
SuppressUnusedWarnings (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) (a6989586621679142401 :: k) Source # | |
Defined in Data.Eq.Singletons type Apply (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) (a6989586621679142401 :: k) = DefaultEqSym1 a6989586621679142401 |
data DefaultEqSym1 (a6989586621679142401 :: k) :: (~>) k Bool Source #
Instances
SuppressUnusedWarnings (DefaultEqSym1 a6989586621679142401 :: TyFun k Bool -> Type) Source # | |
Defined in Data.Eq.Singletons suppressUnusedWarnings :: () # | |
type Apply (DefaultEqSym1 a6989586621679142401 :: TyFun k Bool -> Type) (a6989586621679142402 :: k) Source # | |
Defined in Data.Eq.Singletons type Apply (DefaultEqSym1 a6989586621679142401 :: TyFun k Bool -> Type) (a6989586621679142402 :: k) = DefaultEq a6989586621679142401 a6989586621679142402 |
type family DefaultEqSym2 (a6989586621679142401 :: k) (a6989586621679142402 :: k) :: Bool where ... Source #
DefaultEqSym2 a6989586621679142401 a6989586621679142402 = DefaultEq a6989586621679142401 a6989586621679142402 |