Copyright | (C) 2013 Richard Eisenberg |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Ryan Scott |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | GHC2021 |
Data.Eq.Singletons
Contents
Description
Synopsis
- class PEq a where
- class SEq a where
- type family DefaultEq (a :: k) (b :: k) :: Bool where ...
- data (==@#@$) (a1 :: TyFun a (a ~> Bool))
- data (a6989586621679128025 :: a) ==@#@$$ (b :: TyFun a Bool)
- type family (a6989586621679128025 :: a) ==@#@$$$ (a6989586621679128026 :: a) :: Bool where ...
- data (/=@#@$) (a1 :: TyFun a (a ~> Bool))
- data (a6989586621679128030 :: a) /=@#@$$ (b :: TyFun a Bool)
- type family (a6989586621679128030 :: a) /=@#@$$$ (a6989586621679128031 :: a) :: Bool where ...
- data DefaultEqSym0 (a :: TyFun k (k ~> Bool))
- data DefaultEqSym1 (a6989586621679129674 :: k) (b :: TyFun k Bool)
- type family DefaultEqSym2 (a6989586621679129674 :: k) (a6989586621679129675 :: k) :: Bool where ...
Documentation
Associated Types
type (arg :: a) == (arg1 :: a) :: Bool infix 4 Source #
type (arg :: a) == (arg1 :: a) = TFHelper_6989586621679128045 arg arg1
type (arg :: a) /= (arg1 :: a) :: Bool infix 4 Source #
type (arg :: a) /= (arg1 :: a) = TFHelper_6989586621679128034 arg arg1
Instances
Minimal complete definition
Nothing
Methods
(%==) :: forall (t1 :: a) (t2 :: a). Sing t1 -> Sing t2 -> Sing (t1 == t2) infix 4 Source #
default (%==) :: forall (t1 :: a) (t2 :: a). (t1 == t2) ~ TFHelper_6989586621679128045 t1 t2 => Sing t1 -> Sing t2 -> Sing (t1 == t2) Source #
(%/=) :: forall (t1 :: a) (t2 :: a). Sing t1 -> Sing t2 -> Sing (t1 /= t2) infix 4 Source #
Instances
SEq Void Source # | |
SEq Bool => SEq All Source # | |
SEq Bool => SEq Any Source # | |
SEq Ordering Source # | |
SEq Natural Source # | |
SEq () Source # | |
SEq Bool Source # | |
SEq Char Source # | |
SEq Symbol Source # | |
SEq a => SEq (First a) Source # | |
SEq a => SEq (Last a) Source # | |
SEq a => SEq (Max a) Source # | |
SEq a => SEq (Min a) Source # | |
SEq m => SEq (WrappedMonoid m) Source # | |
Defined in Data.Semigroup.Singletons.Internal.Wrappers Methods (%==) :: forall (t1 :: WrappedMonoid m) (t2 :: WrappedMonoid m). Sing t1 -> Sing t2 -> Sing (t1 == t2) Source # (%/=) :: forall (t1 :: WrappedMonoid m) (t2 :: WrappedMonoid m). Sing t1 -> Sing t2 -> Sing (t1 /= t2) Source # | |
(SEq a, SEq [a]) => SEq (NonEmpty a) Source # | |
SEq a => SEq (Identity a) Source # | |
SEq (Maybe a) => SEq (First a) Source # | |
SEq (Maybe a) => SEq (Last a) Source # | |
SEq a => SEq (Down a) Source # | |
SEq a => SEq (Dual a) Source # | |
SEq a => SEq (Product a) Source # | |
SEq a => SEq (Sum a) Source # | |
SEq a => SEq (Maybe a) Source # | |
SEq (TYPE rep) Source # | |
(SEq a, SEq [a]) => SEq [a] Source # | |
SEq a => SEq (Arg a b) Source # | |
(SEq a, SEq b) => SEq (Either a b) Source # | |
SEq (Proxy s) Source # | |
(SEq a, SEq b) => SEq (a, b) Source # | |
SEq a => SEq (Const a b) Source # | |
(SEq a, SEq b, SEq c) => SEq (a, b, c) Source # | |
(SEq (f a), SEq (g a)) => SEq (Product f g a) Source # | |
(SEq (f a), SEq (g a)) => SEq (Sum f g a) Source # | |
(SEq a, SEq b, SEq c, SEq d) => SEq (a, b, c, d) Source # | |
SEq (f (g a)) => SEq (Compose f g a) Source # | |
(SEq a, SEq b, SEq c, SEq d, SEq e) => SEq (a, b, c, d, e) Source # | |
(SEq a, SEq b, SEq c, SEq d, SEq e, SEq f) => SEq (a, b, c, d, e, f) Source # | |
(SEq a, SEq b, SEq c, SEq d, SEq e, SEq f, SEq g) => SEq (a, b, c, d, e, f, g) Source # | |
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 (==@#@$) (a1 :: TyFun a (a ~> Bool)) infix 4 Source #
Instances
data (a6989586621679128025 :: a) ==@#@$$ (b :: TyFun a Bool) infix 4 Source #
Instances
SEq a => SingI1 ((==@#@$$) :: a -> TyFun a Bool -> Type) Source # | |
(SEq a, SingI d) => SingI ((==@#@$$) d :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((==@#@$$) a6989586621679128025 :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons Methods suppressUnusedWarnings :: () # | |
type Apply ((==@#@$$) a6989586621679128025 :: TyFun a Bool -> Type) (a6989586621679128026 :: a) Source # | |
type family (a6989586621679128025 :: a) ==@#@$$$ (a6989586621679128026 :: a) :: Bool where ... infix 4 Source #
data (/=@#@$) (a1 :: TyFun a (a ~> Bool)) infix 4 Source #
Instances
data (a6989586621679128030 :: a) /=@#@$$ (b :: TyFun a Bool) infix 4 Source #
Instances
SEq a => SingI1 ((/=@#@$$) :: a -> TyFun a Bool -> Type) Source # | |
(SEq a, SingI d) => SingI ((/=@#@$$) d :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons | |
SuppressUnusedWarnings ((/=@#@$$) a6989586621679128030 :: TyFun a Bool -> Type) Source # | |
Defined in Data.Eq.Singletons Methods suppressUnusedWarnings :: () # | |
type Apply ((/=@#@$$) a6989586621679128030 :: TyFun a Bool -> Type) (a6989586621679128031 :: a) Source # | |
type family (a6989586621679128030 :: a) /=@#@$$$ (a6989586621679128031 :: a) :: Bool where ... infix 4 Source #
data DefaultEqSym0 (a :: TyFun k (k ~> Bool)) Source #
Instances
SuppressUnusedWarnings (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) Source # | |
Defined in Data.Eq.Singletons Methods suppressUnusedWarnings :: () # | |
type Apply (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) (a6989586621679129674 :: k) Source # | |
Defined in Data.Eq.Singletons type Apply (DefaultEqSym0 :: TyFun k (k ~> Bool) -> Type) (a6989586621679129674 :: k) = DefaultEqSym1 a6989586621679129674 |
data DefaultEqSym1 (a6989586621679129674 :: k) (b :: TyFun k Bool) Source #
Instances
SuppressUnusedWarnings (DefaultEqSym1 a6989586621679129674 :: TyFun k Bool -> Type) Source # | |
Defined in Data.Eq.Singletons Methods suppressUnusedWarnings :: () # | |
type Apply (DefaultEqSym1 a6989586621679129674 :: TyFun k Bool -> Type) (a6989586621679129675 :: k) Source # | |
Defined in Data.Eq.Singletons |
type family DefaultEqSym2 (a6989586621679129674 :: k) (a6989586621679129675 :: k) :: Bool where ... Source #
Equations
DefaultEqSym2 (a6989586621679129674 :: k) (a6989586621679129675 :: k) = DefaultEq a6989586621679129674 a6989586621679129675 |