parameterized-utils-2.1.11.0: Classes and data structures for working with data-kind indexed types

Copyright | (c) Galois Inc 2014-2019
Maintainer | Joe Hendrix <jhendrix@galois.com>
Safe Haskell | Safe
Language | Haskell2010

Data.Parameterized.Classes

Contents

- Equality exports
- Ordering generalization
- Typeclass generalizations
- Type function application constructor
- Optics generalizations
- KnownRepr
- Re-exports

Description

This module declares classes for working with types with the kind `k -> *` for any kind `k`. These are generalizations of the Data.Functor.Classes types as they work with any kind `k`, and are not restricted to `*`.

Synopsis

- class TestEquality (f :: k -> Type) where
  - testEquality :: forall (a :: k) (b :: k). f a -> f b -> Maybe (a :~: b)
- data (a :: k) :~: (b :: k) where
  - Refl :: forall {k} (a :: k). a :~: a
- class EqF (f :: k -> Type) where
  - eqF :: forall (a :: k). f a -> f a -> Bool
- class PolyEq u v where
  - polyEqF :: u -> v -> Maybe (u :~: v)
  - polyEq :: u -> v -> Bool
- class TestEquality ktp => OrdF (ktp :: k -> Type) where
  - compareF :: forall (x :: k) (y :: k). ktp x -> ktp y -> OrderingF x y
  - leqF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool
  - ltF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool
  - geqF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool
  - gtF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool
- lexCompareF :: forall j k f (a :: j) (b :: j) (c :: k) (d :: k). OrdF f => f a -> f b -> (a ~ b => OrderingF c d) -> OrderingF c d
- data OrderingF (x :: k) (y :: k) where
  - LTF :: forall {k} (x :: k) (y :: k). OrderingF x y
  - EQF :: forall {k} (x :: k). OrderingF x x
  - GTF :: forall {k} (x :: k) (y :: k). OrderingF x y
- joinOrderingF :: forall j k (a :: j) (b :: j) (c :: k) (d :: k). OrderingF a b -> (a ~ b => OrderingF c d) -> OrderingF c d
- orderingF_refl :: forall {k} (x :: k) (y :: k). OrderingF x y -> Maybe (x :~: y)
- toOrdering :: forall {k} (x :: k) (y :: k). OrderingF x y -> Ordering
- fromOrdering :: forall {k} (x :: k). Ordering -> OrderingF x x
- ordFCompose :: forall k l f (g :: l -> k) (x :: l) (y :: l). (forall (w :: k) (z :: k). f w -> f z -> OrderingF w z) -> Compose f g x -> Compose f g y -> OrderingF x y
- class ShowF (f :: k -> Type) where
  - withShow :: forall p q (tp :: k) a. p f -> q tp -> (Show (f tp) => a) -> a
  - showF :: forall (tp :: k). f tp -> String
  - showsPrecF :: forall (tp :: k). Int -> f tp -> String -> String
- showsF :: forall {k} f (tp :: k). ShowF f => f tp -> String -> String
- class HashableF (f :: k -> Type) where
  - hashWithSaltF :: forall (tp :: k). Int -> f tp -> Int
  - hashF :: forall (tp :: k). f tp -> Int
- class CoercibleF (rtp :: k -> Type) where
  - coerceF :: forall (a :: k) (b :: k). rtp a -> rtp b
- newtype TypeAp (f :: k -> Type) (tp :: k) = TypeAp (f tp)
- type family IndexF m :: k -> Type
- type family IxValueF m :: k -> Type
- class IxedF k m where
  - ixF :: forall (x :: k). IndexF m x -> Traversal' m (IxValueF m x)
- class IxedF k m => IxedF' k m where
  - ixF' :: forall (x :: k). IndexF m x -> Lens' m (IxValueF m x)
- class IxedF k m => AtF k m where
  - atF :: forall (x :: k). IndexF m x -> Lens' m (Maybe (IxValueF m x))
- class KnownRepr (f :: k -> Type) (ctx :: k) where
  - knownRepr :: f ctx
- class Eq a => Hashable a where
  - hashWithSalt :: Int -> a -> Int
  - hash :: a -> Int
- isJust :: Maybe a -> Bool

# Equality exports

class TestEquality (f :: k -> Type) where Source #

This class contains types where you can learn the equality of two types from information contained in terms.

The result should be `Just Refl` if and only if the types applied to `f` are equal:

    testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b

Typically, only singleton types should inhabit this class. In that case type argument equality coincides with term equality:

    testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y

    isJust (testEquality x y) = x == y

Singleton types are not required, however, and so the latter two would-be laws are not in fact valid in general.

Methods

testEquality :: forall (a :: k) (b :: k). f a -> f b -> Maybe (a :~: b) Source #

Conditionally prove the equality of `a` and `b`.

#### Instances

Instances details

TestEquality SNat | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.TypeNats Methods testEquality :: forall (a :: Nat) (b :: Nat). SNat a -> SNat b -> Maybe (a :~: b) Source #
TestEquality NatRepr Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods testEquality :: forall (a :: Nat) (b :: Nat). NatRepr a -> NatRepr b -> Maybe (a :~: b) Source #
TestEquality PeanoRepr Source # |
Instance details Defined in Data.Parameterized.Peano Methods testEquality :: forall (a :: Peano) (b :: Peano). PeanoRepr a -> PeanoRepr b -> Maybe (a :~: b) Source #
TestEquality BoolRepr Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods testEquality :: forall (a :: Bool) (b :: Bool). BoolRepr a -> BoolRepr b -> Maybe (a :~: b) Source #
TestEquality SChar | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.TypeLits Methods testEquality :: forall (a :: Char) (b :: Char). SChar a -> SChar b -> Maybe (a :~: b) Source #
TestEquality SSymbol | Since: base-4.18.0.0
Instance details Defined in GHC.Internal.TypeLits Methods testEquality :: forall (a :: Symbol) (b :: Symbol). SSymbol a -> SSymbol b -> Maybe (a :~: b) Source #
TestEquality SymbolRepr Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods testEquality :: forall (a :: Symbol) (b :: Symbol). SymbolRepr a -> SymbolRepr b -> Maybe (a :~: b) Source #
TestEquality (TypeRep :: k -> Type) |
Instance details Defined in GHC.Internal.Data.Typeable.Internal Methods testEquality :: forall (a :: k) (b :: k). TypeRep a -> TypeRep b -> Maybe (a :~: b) Source #
TestEquality (Nonce :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce.Unsafe Methods testEquality :: forall (a :: k) (b :: k). Nonce a -> Nonce b -> Maybe (a :~: b) Source #
TestEquality ((:~:) a :: k -> Type) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods testEquality :: forall (a0 :: k) (b :: k). (a :~: a0) -> (a :~: b) -> Maybe (a0 :~: b) Source #
TestEquality (Index ctx :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods testEquality :: forall (a :: k) (b :: k). Index ctx a -> Index ctx b -> Maybe (a :~: b) Source #
TestEquality (Index l :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.List Methods testEquality :: forall (a :: k) (b :: k). Index l a -> Index l b -> Maybe (a :~: b) Source #
TestEquality (Nonce s :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce Methods testEquality :: forall (a :: k) (b :: k). Nonce s a -> Nonce s b -> Maybe (a :~: b) Source #
TestEquality ((:~~:) a :: k -> Type) | Since: base-4.10.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods testEquality :: forall (a0 :: k) (b :: k). (a :~~: a0) -> (a :~~: b) -> Maybe (a0 :~: b) Source #
TestEquality f => TestEquality (Compose f g :: k2 -> Type) | The deduction (via generativity) that if `g x :~: g y` then `x :~: y`. Since: base-4.14.0.0
Instance details Defined in Data.Functor.Compose Methods testEquality :: forall (a :: k2) (b :: k2). Compose f g a -> Compose f g b -> Maybe (a :~: b) Source #
TestEquality f => TestEquality (Assignment f :: Ctx k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods testEquality :: forall (a :: Ctx k) (b :: Ctx k). Assignment f a -> Assignment f b -> Maybe (a :~: b) Source #
TestEquality f => TestEquality (List f :: [k] -> Type) Source # |
Instance details Defined in Data.Parameterized.List Methods testEquality :: forall (a :: [k]) (b :: [k]). List f a -> List f b -> Maybe (a :~: b) Source #
(TestEquality f, TestEquality g) => TestEquality (PairRepr f g :: (k1, k2) -> Type) Source # |
Instance details Defined in Data.Parameterized.DataKind Methods testEquality :: forall (a :: (k1, k2)) (b :: (k1, k2)). PairRepr f g a -> PairRepr f g b -> Maybe (a :~: b) Source #

data (a :: k) :~: (b :: k) where infix 4 Source #

Propositional equality. If `a :~: b` is inhabited by some terminating value, then the type `a` is the same as the type `b`. To use this equality in practice, pattern-match on the `a :~: b` to get out the `Refl` constructor; in the body of the pattern-match, the compiler knows that `a ~ b`.

Since: base-4.7.0.0

Constructors

Refl :: forall {k} (a :: k). a :~: a |

#### Instances

Instances details

Category ((:~:) :: k -> k -> Type) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Control.Category Methods id :: forall (a :: k). a :~: a Source # (.) :: forall (b :: k) (c :: k) (a :: k). (b :~: c) -> (a :~: b) -> a :~: c Source #
TestEquality ((:~:) a :: k -> Type) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods testEquality :: forall (a0 :: k) (b :: k). (a :~: a0) -> (a :~: b) -> Maybe (a0 :~: b) Source #
NFData2 ((:~:) :: Type -> Type -> Type) | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf2 :: (a -> ()) -> (b -> ()) -> (a :~: b) -> () Source #
NFData1 ((:~:) a) | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a0 -> ()) -> (a :~: a0) -> () Source #
NFData (a :~: b) | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods rnf :: (a :~: b) -> () Source #
(a ~ b, Data a) => Data (a :~: b) | Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Data.Data

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> (a :~: b) -> c (a :~: b) Source #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (a :~: b) Source #

toConstr :: (a :~: b) -> Constr Source #

dataTypeOf :: (a :~: b) -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (a :~: b)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (a :~: b)) Source #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> (a :~: b) -> a :~: b Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> (a :~: b) -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> (a :~: b) -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> (a :~: b) -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> (a :~: b) -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> (a :~: b) -> m (a :~: b) Source #

a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods minBound :: a :~: b Source # maxBound :: a :~: b Source #
a ~ b => Enum (a :~: b) | Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Data.Type.Equality

Methods

succ :: (a :~: b) -> a :~: b Source #

pred :: (a :~: b) -> a :~: b Source #

toEnum :: Int -> a :~: b Source #

fromEnum :: (a :~: b) -> Int Source #

enumFrom :: (a :~: b) -> [a :~: b] Source #

enumFromThen :: (a :~: b) -> (a :~: b) -> [a :~: b] Source #

enumFromTo :: (a :~: b) -> (a :~: b) -> [a :~: b] Source #

enumFromThenTo :: (a :~: b) -> (a :~: b) -> (a :~: b) -> [a :~: b] Source #

a ~ b => Read (a :~: b) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods readsPrec :: Int -> ReadS (a :~: b) Source # readList :: ReadS [a :~: b] Source # readPrec :: ReadPrec (a :~: b) Source # readListPrec :: ReadPrec [a :~: b] Source #
Show (a :~: b) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods showsPrec :: Int -> (a :~: b) -> ShowS Source # show :: (a :~: b) -> String Source # showList :: [a :~: b] -> ShowS Source #
Eq (a :~: b) | Since: base-4.7.0.0
Instance details Defined in GHC.Internal.Data.Type.Equality Methods (==) :: (a :~: b) -> (a :~: b) -> Bool Source # (/=) :: (a :~: b) -> (a :~: b) -> Bool Source #
Ord (a :~: b) | Since: base-4.7.0.0

Instance details

Defined in GHC.Internal.Data.Type.Equality

Methods

compare :: (a :~: b) -> (a :~: b) -> Ordering Source #

(<) :: (a :~: b) -> (a :~: b) -> Bool Source #

(<=) :: (a :~: b) -> (a :~: b) -> Bool Source #

(>) :: (a :~: b) -> (a :~: b) -> Bool Source #

(>=) :: (a :~: b) -> (a :~: b) -> Bool Source #

max :: (a :~: b) -> (a :~: b) -> a :~: b Source #

min :: (a :~: b) -> (a :~: b) -> a :~: b Source #

HasDict (a ~ b) (a :~: b) |
Instance details Defined in Data.Constraint Methods evidence :: (a :~: b) -> Dict (a ~ b) Source #

class EqF (f :: k -> Type) where Source #

`EqF` provides a method `eqF` for testing whether two parameterized types are equal.

Unlike `TestEquality`, this only works when the type arguments are the same, and does not provide a proof that the types have the same type when they are equal. Thus this can be implemented over parameterized types that are unable to provide evidence that their type arguments are equal.

Methods

eqF :: forall (a :: k). f a -> f a -> Bool Source #

#### Instances

Instances details

EqF NatRepr Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods eqF :: forall (a :: Nat). NatRepr a -> NatRepr a -> Bool Source #
EqF PeanoRepr Source # |
Instance details Defined in Data.Parameterized.Peano Methods eqF :: forall (a :: Peano). PeanoRepr a -> PeanoRepr a -> Bool Source #
EqF BoolRepr Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods eqF :: forall (a :: Bool). BoolRepr a -> BoolRepr a -> Bool Source #
EqF SymbolRepr Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods eqF :: forall (a :: Symbol). SymbolRepr a -> SymbolRepr a -> Bool Source #
EqF (Proxy :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods eqF :: forall (a :: k). Proxy a -> Proxy a -> Bool Source #
EqF (Nonce :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce.Unsafe Methods eqF :: forall (a :: k). Nonce a -> Nonce a -> Bool Source #
Eq a => EqF (Const a :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods eqF :: forall (a0 :: k). Const a a0 -> Const a a0 -> Bool Source #
EqF (Index ctx :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods eqF :: forall (a :: k). Index ctx a -> Index ctx a -> Bool Source #
EqF (Nonce s :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce Methods eqF :: forall (a :: k). Nonce s a -> Nonce s a -> Bool Source #
EqF f => EqF (Assignment f :: Ctx k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods eqF :: forall (a :: Ctx k). Assignment f a -> Assignment f a -> Bool Source #
EqF f => EqF (List f :: [k] -> Type) Source # |
Instance details Defined in Data.Parameterized.List Methods eqF :: forall (a :: [k]). List f a -> List f a -> Bool Source #
(EqF f, EqF g) => EqF (PairRepr f g :: (k1, k2) -> Type) Source # |
Instance details Defined in Data.Parameterized.DataKind Methods eqF :: forall (a :: (k1, k2)). PairRepr f g a -> PairRepr f g a -> Bool Source #

class PolyEq u v where Source #

A polymorphic equality operator that generalizes `TestEquality`.

Minimal complete definition

polyEqF

Methods

polyEqF :: u -> v -> Maybe (u :~: v) Source #

polyEq :: u -> v -> Bool Source #

#### Instances

Instances details

PolyEq (BoolRepr m) (BoolRepr n) Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods polyEqF :: BoolRepr m -> BoolRepr n -> Maybe (BoolRepr m :~: BoolRepr n) Source # polyEq :: BoolRepr m -> BoolRepr n -> Bool Source #
PolyEq (NatRepr m) (NatRepr n) Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods polyEqF :: NatRepr m -> NatRepr n -> Maybe (NatRepr m :~: NatRepr n) Source # polyEq :: NatRepr m -> NatRepr n -> Bool Source #
PolyEq (PeanoRepr m) (PeanoRepr n) Source # |
Instance details Defined in Data.Parameterized.Peano Methods polyEqF :: PeanoRepr m -> PeanoRepr n -> Maybe (PeanoRepr m :~: PeanoRepr n) Source # polyEq :: PeanoRepr m -> PeanoRepr n -> Bool Source #

# Ordering generalization

class TestEquality ktp => OrdF (ktp :: k -> Type) where Source #

The `OrdF` class is a total ordering over parameterized types so that types with different parameters can be compared.

Instances of `OrdF` are expected to satisfy the following laws:

Transitivity
  if `leqF x y && leqF y z` = `True`, then `leqF x = z` = `True`
Reflexivity
  `leqF x x` = `True`
Antisymmetry
  if `leqF x y && leqF y x` = `True`, then `testEquality x y` = `Just Refl`

Note that the following operator interactions are expected to hold:

- `geqF x y` iff `leqF y x`
- `ltF x y` iff `leqF x y && testEquality x y = Nothing`
- `gtF x y` iff `ltF y x`
- `ltF x y` iff `compareF x y == LTF`
- `gtF x y` iff `compareF x y == GTF`
- `isJust (testEquality x y)` iff `compareF x y == EQF`

Furthermore, when `x` and `y` both have type `(k tp)`, we expect:

- `toOrdering (compareF x y)` equals `compare x y` when `Ord (k tp)` has an instance.
- `isJust (testEquality x y)` equals `x == y` when `Eq (k tp)` has an instance.

Minimal complete definition: either `compareF` or `leqF`. Using `compareF` can be more efficient for complex types.

Minimal complete definition

compareF | leqF

Methods

compareF :: forall (x :: k) (y :: k). ktp x -> ktp y -> OrderingF x y Source #

leqF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool Source #

ltF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool Source #

geqF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool Source #

gtF :: forall (x :: k) (y :: k). ktp x -> ktp y -> Bool Source #

#### Instances

Instances details

OrdF NatRepr Source # |

Instance details

Defined in Data.Parameterized.NatRepr.Internal

Methods

compareF :: forall (x :: Nat) (y :: Nat). NatRepr x -> NatRepr y -> OrderingF x y Source #

leqF :: forall (x :: Nat) (y :: Nat). NatRepr x -> NatRepr y -> Bool Source #

ltF :: forall (x :: Nat) (y :: Nat). NatRepr x -> NatRepr y -> Bool Source #

geqF :: forall (x :: Nat) (y :: Nat). NatRepr x -> NatRepr y -> Bool Source #

gtF :: forall (x :: Nat) (y :: Nat). NatRepr x -> NatRepr y -> Bool Source #

OrdF PeanoRepr Source # |

Instance details

Defined in Data.Parameterized.Peano

Methods

compareF :: forall (x :: Peano) (y :: Peano). PeanoRepr x -> PeanoRepr y -> OrderingF x y Source #

leqF :: forall (x :: Peano) (y :: Peano). PeanoRepr x -> PeanoRepr y -> Bool Source #

ltF :: forall (x :: Peano) (y :: Peano). PeanoRepr x -> PeanoRepr y -> Bool Source #

geqF :: forall (x :: Peano) (y :: Peano). PeanoRepr x -> PeanoRepr y -> Bool Source #

gtF :: forall (x :: Peano) (y :: Peano). PeanoRepr x -> PeanoRepr y -> Bool Source #

OrdF BoolRepr Source # |

Instance details

Defined in Data.Parameterized.BoolRepr

Methods

compareF :: forall (x :: Bool) (y :: Bool). BoolRepr x -> BoolRepr y -> OrderingF x y Source #

leqF :: forall (x :: Bool) (y :: Bool). BoolRepr x -> BoolRepr y -> Bool Source #

ltF :: forall (x :: Bool) (y :: Bool). BoolRepr x -> BoolRepr y -> Bool Source #

geqF :: forall (x :: Bool) (y :: Bool). BoolRepr x -> BoolRepr y -> Bool Source #

gtF :: forall (x :: Bool) (y :: Bool). BoolRepr x -> BoolRepr y -> Bool Source #

OrdF SymbolRepr Source # |

Instance details

Defined in Data.Parameterized.SymbolRepr

Methods

compareF :: forall (x :: Symbol) (y :: Symbol). SymbolRepr x -> SymbolRepr y -> OrderingF x y Source #

leqF :: forall (x :: Symbol) (y :: Symbol). SymbolRepr x -> SymbolRepr y -> Bool Source #

ltF :: forall (x :: Symbol) (y :: Symbol). SymbolRepr x -> SymbolRepr y -> Bool Source #

geqF :: forall (x :: Symbol) (y :: Symbol). SymbolRepr x -> SymbolRepr y -> Bool Source #

gtF :: forall (x :: Symbol) (y :: Symbol). SymbolRepr x -> SymbolRepr y -> Bool Source #

OrdF (Nonce :: k -> Type) Source # |

Instance details

Defined in Data.Parameterized.Nonce.Unsafe

Methods

compareF :: forall (x :: k) (y :: k). Nonce x -> Nonce y -> OrderingF x y Source #

leqF :: forall (x :: k) (y :: k). Nonce x -> Nonce y -> Bool Source #

ltF :: forall (x :: k) (y :: k). Nonce x -> Nonce y -> Bool Source #

geqF :: forall (x :: k) (y :: k). Nonce x -> Nonce y -> Bool Source #

gtF :: forall (x :: k) (y :: k). Nonce x -> Nonce y -> Bool Source #

OrdF (Index ctx :: k -> Type) Source # |

Instance details

Defined in Data.Parameterized.Context.Unsafe

Methods

compareF :: forall (x :: k) (y :: k). Index ctx x -> Index ctx y -> OrderingF x y Source #

leqF :: forall (x :: k) (y :: k). Index ctx x -> Index ctx y -> Bool Source #

ltF :: forall (x :: k) (y :: k). Index ctx x -> Index ctx y -> Bool Source #

geqF :: forall (x :: k) (y :: k). Index ctx x -> Index ctx y -> Bool Source #

gtF :: forall (x :: k) (y :: k). Index ctx x -> Index ctx y -> Bool Source #

OrdF (Index l :: k -> Type) Source # |

Instance details

Defined in Data.Parameterized.List

Methods

compareF :: forall (x :: k) (y :: k). Index l x -> Index l y -> OrderingF x y Source #

leqF :: forall (x :: k) (y :: k). Index l x -> Index l y -> Bool Source #

ltF :: forall (x :: k) (y :: k). Index l x -> Index l y -> Bool Source #

geqF :: forall (x :: k) (y :: k). Index l x -> Index l y -> Bool Source #

gtF :: forall (x :: k) (y :: k). Index l x -> Index l y -> Bool Source #

OrdF (Nonce s :: k -> Type) Source # |

Instance details

Defined in Data.Parameterized.Nonce

Methods

compareF :: forall (x :: k) (y :: k). Nonce s x -> Nonce s y -> OrderingF x y Source #

leqF :: forall (x :: k) (y :: k). Nonce s x -> Nonce s y -> Bool Source #

ltF :: forall (x :: k) (y :: k). Nonce s x -> Nonce s y -> Bool Source #

geqF :: forall (x :: k) (y :: k). Nonce s x -> Nonce s y -> Bool Source #

gtF :: forall (x :: k) (y :: k). Nonce s x -> Nonce s y -> Bool Source #

OrdF f => OrdF (Compose f g :: k2 -> Type) Source # |

Instance details

Defined in Data.Parameterized.Classes

Methods

compareF :: forall (x :: k2) (y :: k2). Compose f g x -> Compose f g y -> OrderingF x y Source #

leqF :: forall (x :: k2) (y :: k2). Compose f g x -> Compose f g y -> Bool Source #

ltF :: forall (x :: k2) (y :: k2). Compose f g x -> Compose f g y -> Bool Source #

geqF :: forall (x :: k2) (y :: k2). Compose f g x -> Compose f g y -> Bool Source #

gtF :: forall (x :: k2) (y :: k2). Compose f g x -> Compose f g y -> Bool Source #

OrdF f => OrdF (Assignment f :: Ctx k -> Type) Source # |

Instance details

Defined in Data.Parameterized.Context.Unsafe

Methods

compareF :: forall (x :: Ctx k) (y :: Ctx k). Assignment f x -> Assignment f y -> OrderingF x y Source #

leqF :: forall (x :: Ctx k) (y :: Ctx k). Assignment f x -> Assignment f y -> Bool Source #

ltF :: forall (x :: Ctx k) (y :: Ctx k). Assignment f x -> Assignment f y -> Bool Source #

geqF :: forall (x :: Ctx k) (y :: Ctx k). Assignment f x -> Assignment f y -> Bool Source #

gtF :: forall (x :: Ctx k) (y :: Ctx k). Assignment f x -> Assignment f y -> Bool Source #

OrdF f => OrdF (List f :: [k] -> Type) Source # |

Instance details

Defined in Data.Parameterized.List

Methods

compareF :: forall (x :: [k]) (y :: [k]). List f x -> List f y -> OrderingF x y Source #

leqF :: forall (x :: [k]) (y :: [k]). List f x -> List f y -> Bool Source #

ltF :: forall (x :: [k]) (y :: [k]). List f x -> List f y -> Bool Source #

geqF :: forall (x :: [k]) (y :: [k]). List f x -> List f y -> Bool Source #

gtF :: forall (x :: [k]) (y :: [k]). List f x -> List f y -> Bool Source #

(OrdF f, OrdF g) => OrdF (PairRepr f g :: (k1, k2) -> Type) Source # |

Instance details

Defined in Data.Parameterized.DataKind

Methods

compareF :: forall (x :: (k1, k2)) (y :: (k1, k2)). PairRepr f g x -> PairRepr f g y -> OrderingF x y Source #

leqF :: forall (x :: (k1, k2)) (y :: (k1, k2)). PairRepr f g x -> PairRepr f g y -> Bool Source #

ltF :: forall (x :: (k1, k2)) (y :: (k1, k2)). PairRepr f g x -> PairRepr f g y -> Bool Source #

geqF :: forall (x :: (k1, k2)) (y :: (k1, k2)). PairRepr f g x -> PairRepr f g y -> Bool Source #

gtF :: forall (x :: (k1, k2)) (y :: (k1, k2)). PairRepr f g x -> PairRepr f g y -> Bool Source #

lexCompareF :: forall j k f (a :: j) (b :: j) (c :: k) (d :: k). OrdF f => f a -> f b -> (a ~ b => OrderingF c d) -> OrderingF c d Source #

Compare two values, and if they are equal compare the next values, otherwise return LTF or GTF

data OrderingF (x :: k) (y :: k) where Source #

Ordering over two distinct types with a proof they are equal.

Constructors

LTF :: forall {k} (x :: k) (y :: k). OrderingF x y |
EQF :: forall {k} (x :: k). OrderingF x x |
GTF :: forall {k} (x :: k) (y :: k). OrderingF x y |

joinOrderingF :: forall j k (a :: j) (b :: j) (c :: k) (d :: k). OrderingF a b -> (a ~ b => OrderingF c d) -> OrderingF c d Source #

`joinOrderingF x y` first compares on `x`, returning an equivalent value if it is not `EQF`. If it is `EQF`, it returns `y`.

orderingF_refl :: forall {k} (x :: k) (y :: k). OrderingF x y -> Maybe (x :~: y) Source #

toOrdering :: forall {k} (x :: k) (y :: k). OrderingF x y -> Ordering Source #

Convert `OrderingF` to standard ordering.

fromOrdering :: forall {k} (x :: k). Ordering -> OrderingF x x Source #

Convert standard ordering to `OrderingF`.

ordFCompose :: forall k l f (g :: l -> k) (x :: l) (y :: l). (forall (w :: k) (z :: k). f w -> f z -> OrderingF w z) -> Compose f g x -> Compose f g y -> OrderingF x y Source #

If the "outer" functor has an `OrdF` instance, then one can be generated for the "inner" functor. The type-level evidence of equality is deduced via generativity of `g`, e.g. the inference `g x ~ g y` implies `x ~ y`.

# Typeclass generalizations

class ShowF (f :: k -> Type) where Source #

A parameterized type that can be shown on all instances.

To implement ``ShowF` g`, one should implement an instance ``Show` (g tp)` for all argument types `tp`, then write an empty instance `instance `ShowF` g`.

Minimal complete definition

Nothing

Methods

withShow :: forall p q (tp :: k) a. p f -> q tp -> (Show (f tp) => a) -> a Source #

Provides a show instance for each type.

default withShow :: forall (tp :: k) p q a. Show (f tp) => p f -> q tp -> (Show (f tp) => a) -> a Source #

showF :: forall (tp :: k). f tp -> String Source #

showsPrecF :: forall (tp :: k). Int -> f tp -> String -> String Source #

Like `showsPrec`, the precedence argument is one more than the precedence of the enclosing context.

#### Instances

Instances details

ShowF NatRepr Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods withShow :: forall p q (tp :: Nat) a. p NatRepr -> q tp -> (Show (NatRepr tp) => a) -> a Source # showF :: forall (tp :: Nat). NatRepr tp -> String Source # showsPrecF :: forall (tp :: Nat). Int -> NatRepr tp -> String -> String Source #
ShowF PeanoRepr Source # |
Instance details Defined in Data.Parameterized.Peano Methods withShow :: forall p q (tp :: Peano) a. p PeanoRepr -> q tp -> (Show (PeanoRepr tp) => a) -> a Source # showF :: forall (tp :: Peano). PeanoRepr tp -> String Source # showsPrecF :: forall (tp :: Peano). Int -> PeanoRepr tp -> String -> String Source #
ShowF BoolRepr Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods withShow :: forall p q (tp :: Bool) a. p BoolRepr -> q tp -> (Show (BoolRepr tp) => a) -> a Source # showF :: forall (tp :: Bool). BoolRepr tp -> String Source # showsPrecF :: forall (tp :: Bool). Int -> BoolRepr tp -> String -> String Source #
ShowF SymbolRepr Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods withShow :: forall p q (tp :: Symbol) a. p SymbolRepr -> q tp -> (Show (SymbolRepr tp) => a) -> a Source # showF :: forall (tp :: Symbol). SymbolRepr tp -> String Source # showsPrecF :: forall (tp :: Symbol). Int -> SymbolRepr tp -> String -> String Source #
ShowF (Proxy :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods withShow :: forall p q (tp :: k) a. p (Proxy :: k -> Type) -> q tp -> (Show (Proxy tp) => a) -> a Source # showF :: forall (tp :: k). Proxy tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Proxy tp -> String -> String Source #
ShowF (Nonce :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce.Unsafe Methods withShow :: forall p q (tp :: k) a. p (Nonce :: k -> Type) -> q tp -> (Show (Nonce tp) => a) -> a Source # showF :: forall (tp :: k). Nonce tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Nonce tp -> String -> String Source #
Show x => ShowF (Const x :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods withShow :: forall p q (tp :: k) a. p (Const x :: k -> Type) -> q tp -> (Show (Const x tp) => a) -> a Source # showF :: forall (tp :: k). Const x tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Const x tp -> String -> String Source #
ShowF (Index ctx :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods withShow :: forall p q (tp :: k) a. p (Index ctx) -> q tp -> (Show (Index ctx tp) => a) -> a Source # showF :: forall (tp :: k). Index ctx tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Index ctx tp -> String -> String Source #
ShowF (IndexView ctx :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods withShow :: forall p q (tp :: k) a. p (IndexView ctx) -> q tp -> (Show (IndexView ctx tp) => a) -> a Source # showF :: forall (tp :: k). IndexView ctx tp -> String Source # showsPrecF :: forall (tp :: k). Int -> IndexView ctx tp -> String -> String Source #
ShowF (Index l :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.List Methods withShow :: forall p q (tp :: k) a. p (Index l) -> q tp -> (Show (Index l tp) => a) -> a Source # showF :: forall (tp :: k). Index l tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Index l tp -> String -> String Source #
ShowF (Nonce s :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce Methods withShow :: forall p q (tp :: k) a. p (Nonce s :: k -> Type) -> q tp -> (Show (Nonce s tp) => a) -> a Source # showF :: forall (tp :: k). Nonce s tp -> String Source # showsPrecF :: forall (tp :: k). Int -> Nonce s tp -> String -> String Source #
ShowF (Size :: Ctx k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods withShow :: forall p q (tp :: Ctx k) a. p (Size :: Ctx k -> Type) -> q tp -> (Show (Size tp) => a) -> a Source # showF :: forall (tp :: Ctx k). Size tp -> String Source # showsPrecF :: forall (tp :: Ctx k). Int -> Size tp -> String -> String Source #
ShowF f => ShowF (Assignment f :: Ctx k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods withShow :: forall p q (tp :: Ctx k) a. p (Assignment f) -> q tp -> (Show (Assignment f tp) => a) -> a Source # showF :: forall (tp :: Ctx k). Assignment f tp -> String Source # showsPrecF :: forall (tp :: Ctx k). Int -> Assignment f tp -> String -> String Source #
ShowF f => ShowF (List f :: [k] -> Type) Source # |
Instance details Defined in Data.Parameterized.List Methods withShow :: forall p q (tp :: [k]) a. p (List f) -> q tp -> (Show (List f tp) => a) -> a Source # showF :: forall (tp :: [k]). List f tp -> String Source # showsPrecF :: forall (tp :: [k]). Int -> List f tp -> String -> String Source #
(ShowF f, ShowF g) => ShowF (PairRepr f g :: (k1, k2) -> Type) Source # |
Instance details Defined in Data.Parameterized.DataKind Methods withShow :: forall p q (tp :: (k1, k2)) a. p (PairRepr f g) -> q tp -> (Show (PairRepr f g tp) => a) -> a Source # showF :: forall (tp :: (k1, k2)). PairRepr f g tp -> String Source # showsPrecF :: forall (tp :: (k1, k2)). Int -> PairRepr f g tp -> String -> String Source #

showsF :: forall {k} f (tp :: k). ShowF f => f tp -> String -> String Source #

class HashableF (f :: k -> Type) where Source #

A parameterized type that is hashable on all instances.

Minimal complete definition

hashWithSaltF

Methods

hashWithSaltF :: forall (tp :: k). Int -> f tp -> Int Source #

hashF :: forall (tp :: k). f tp -> Int Source #

Hash with default salt.

#### Instances

Instances details

HashableF NatRepr Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods hashWithSaltF :: forall (tp :: Nat). Int -> NatRepr tp -> Int Source # hashF :: forall (tp :: Nat). NatRepr tp -> Int Source #
HashableF PeanoRepr Source # |
Instance details Defined in Data.Parameterized.Peano Methods hashWithSaltF :: forall (tp :: Peano). Int -> PeanoRepr tp -> Int Source # hashF :: forall (tp :: Peano). PeanoRepr tp -> Int Source #
HashableF BoolRepr Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods hashWithSaltF :: forall (tp :: Bool). Int -> BoolRepr tp -> Int Source # hashF :: forall (tp :: Bool). BoolRepr tp -> Int Source #
HashableF SymbolRepr Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods hashWithSaltF :: forall (tp :: Symbol). Int -> SymbolRepr tp -> Int Source # hashF :: forall (tp :: Symbol). SymbolRepr tp -> Int Source #
HashableF (Nonce :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce.Unsafe Methods hashWithSaltF :: forall (tp :: k). Int -> Nonce tp -> Int Source # hashF :: forall (tp :: k). Nonce tp -> Int Source #
Hashable a => HashableF (Const a :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods hashWithSaltF :: forall (tp :: k). Int -> Const a tp -> Int Source # hashF :: forall (tp :: k). Const a tp -> Int Source #
HashableF (Index ctx :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods hashWithSaltF :: forall (tp :: k). Int -> Index ctx tp -> Int Source # hashF :: forall (tp :: k). Index ctx tp -> Int Source #
HashableF (Nonce s :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Nonce Methods hashWithSaltF :: forall (tp :: k). Int -> Nonce s tp -> Int Source # hashF :: forall (tp :: k). Nonce s tp -> Int Source #
(HashableF f, TestEquality f) => HashableF (Assignment f :: Ctx k -> Type) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods hashWithSaltF :: forall (tp :: Ctx k). Int -> Assignment f tp -> Int Source # hashF :: forall (tp :: Ctx k). Assignment f tp -> Int Source #

class CoercibleF (rtp :: k -> Type) where Source #

An instance of `CoercibleF` gives a way to coerce between all the types of a family. We generally use this to witness the fact that the type parameter to `rtp` is a phantom type by giving an implementation in terms of Data.Coerce.coerce.

Methods

coerceF :: forall (a :: k) (b :: k). rtp a -> rtp b Source #

#### Instances

Instances details

CoercibleF (Const x :: k -> Type) Source # |
Instance details Defined in Data.Parameterized.Classes Methods coerceF :: forall (a :: k) (b :: k). Const x a -> Const x b Source #

# Type function application constructor

newtype TypeAp (f :: k -> Type) (tp :: k) Source #

Captures the value obtained from applying a type to a function so that we can use parameterized class instance to provide unparameterized instances for specific types.

This is the same as `Ap` from `Control.Applicative`, but we introduce our own new type to avoid orphan instances.

Constructors

TypeAp (f tp) |

#### Instances

Instances details

FoldableFC (TypeAp :: (l -> Type) -> l -> Type) Source # |

Instance details

Defined in Data.Parameterized.TraversableFC

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: l). f x -> m) -> forall (x :: l). TypeAp f x -> m Source #

foldrFC :: (forall (x :: l). f x -> b -> b) -> forall (x :: l). b -> TypeAp f x -> b Source #

foldlFC :: forall f b. (forall (x :: l). b -> f x -> b) -> forall (x :: l). b -> TypeAp f x -> b Source #

foldrFC' :: (forall (x :: l). f x -> b -> b) -> forall (x :: l). b -> TypeAp f x -> b Source #

foldlFC' :: forall f b. (forall (x :: l). b -> f x -> b) -> forall (x :: l). b -> TypeAp f x -> b Source #

toListFC :: (forall (x :: l). f x -> a) -> forall (x :: l). TypeAp f x -> [a] Source #

FunctorFC (TypeAp :: (l -> Type) -> l -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableFC Methods fmapFC :: (forall (x :: l). f x -> g x) -> forall (x :: l). TypeAp f x -> TypeAp g x Source #
TraversableFC (TypeAp :: (l -> Type) -> l -> Type) Source # |
Instance details Defined in Data.Parameterized.TraversableFC Methods traverseFC :: forall f g m. Applicative m => (forall (x :: l). f x -> m (g x)) -> forall (x :: l). TypeAp f x -> m (TypeAp g x) Source #
ShowF f => Show (TypeAp f tp) Source # |
Instance details Defined in Data.Parameterized.Classes Methods showsPrec :: Int -> TypeAp f tp -> ShowS Source # show :: TypeAp f tp -> String Source # showList :: [TypeAp f tp] -> ShowS Source #
TestEquality f => Eq (TypeAp f tp) Source # |
Instance details Defined in Data.Parameterized.Classes Methods (==) :: TypeAp f tp -> TypeAp f tp -> Bool Source # (/=) :: TypeAp f tp -> TypeAp f tp -> Bool Source #
OrdF f => Ord (TypeAp f tp) Source # |

Instance details

Defined in Data.Parameterized.Classes

Methods

compare :: TypeAp f tp -> TypeAp f tp -> Ordering Source #

(<) :: TypeAp f tp -> TypeAp f tp -> Bool Source #

(<=) :: TypeAp f tp -> TypeAp f tp -> Bool Source #

(>) :: TypeAp f tp -> TypeAp f tp -> Bool Source #

(>=) :: TypeAp f tp -> TypeAp f tp -> Bool Source #

max :: TypeAp f tp -> TypeAp f tp -> TypeAp f tp Source #

min :: TypeAp f tp -> TypeAp f tp -> TypeAp f tp Source #

(HashableF f, TestEquality f) => Hashable (TypeAp f tp) Source # |
Instance details Defined in Data.Parameterized.Classes Methods hashWithSalt :: Int -> TypeAp f tp -> Int Source # hash :: TypeAp f tp -> Int Source #

# Optics generalizations

type family IndexF m :: k -> Type Source #

#### Instances

Instances details

type IndexF (Assignment f ctx) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe type IndexF (Assignment f ctx) = Index ctx
type IndexF (List f sh) Source # |
Instance details Defined in Data.Parameterized.List type IndexF (List f sh) = Index sh
type IndexF (MapF k2 v) Source # |
Instance details Defined in Data.Parameterized.Map type IndexF (MapF k2 v) = k2

type family IxValueF m :: k -> Type Source #

#### Instances

Instances details

type IxValueF (Assignment f ctx) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe type IxValueF (Assignment f ctx) = f
type IxValueF (List f sh) Source # |
Instance details Defined in Data.Parameterized.List type IxValueF (List f sh) = f
type IxValueF (MapF k2 v) Source # |
Instance details Defined in Data.Parameterized.Map type IxValueF (MapF k2 v) = v

class IxedF k m where Source #

Parameterized generalization of the lens `Ixed` class.

Methods

ixF :: forall (x :: k). IndexF m x -> Traversal' m (IxValueF m x) Source #

Given an index into a container, build a traversal that visits the given element in the container, if it exists.

#### Instances

Instances details

OrdF k => IxedF a (MapF k v) Source # | Turn a map key into a traversal that visits the indicated element in the map, if it exists.
Instance details Defined in Data.Parameterized.Map Methods ixF :: forall (x :: a). IndexF (MapF k v) x -> Traversal' (MapF k v) (IxValueF (MapF k v) x) Source #
IxedF k (Assignment f ctx) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods ixF :: forall (x :: k). IndexF (Assignment f ctx) x -> Traversal' (Assignment f ctx) (IxValueF (Assignment f ctx) x) Source #

class IxedF k m => IxedF' k m where Source #

Parameterized generalization of the lens `Ixed` class, but with the guarantee that indexes exist in the container.

Methods

ixF' :: forall (x :: k). IndexF m x -> Lens' m (IxValueF m x) Source #

Given an index into a container, build a lens that points into the given element in the container.

#### Instances

Instances details

IxedF' k (Assignment f ctx) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods ixF' :: forall (x :: k). IndexF (Assignment f ctx) x -> Lens' (Assignment f ctx) (IxValueF (Assignment f ctx) x) Source #

class IxedF k m => AtF k m where Source #

Parameterized generalization of the lens `At` class.

Methods

atF :: forall (x :: k). IndexF m x -> Lens' m (Maybe (IxValueF m x)) Source #

Given an index into a container, build a lens that points into the given position in the container, whether or not it currently exists. Setting values of `atF` to a `Just` value will insert the value if it does not already exist.

#### Instances

Instances details

OrdF k => AtF a (MapF k v) Source # | Turn a map key into a lens that points into the indicated position in the map.
Instance details Defined in Data.Parameterized.Map Methods atF :: forall (x :: a). IndexF (MapF k v) x -> Lens' (MapF k v) (Maybe (IxValueF (MapF k v) x)) Source #

# KnownRepr

class KnownRepr (f :: k -> Type) (ctx :: k) where Source #

This class is parameterized by a kind `k` (typically a data kind), a type constructor `f` of kind `k -> *` (typically a GADT of singleton types indexed by `k`), and an index parameter `ctx` of kind `k`.

Methods

knownRepr :: f ctx Source #

#### Instances

Instances details

KnownNat n => KnownRepr NatRepr (n :: Nat) Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods knownRepr :: NatRepr n Source #
KnownRepr PeanoRepr Z Source # |
Instance details Defined in Data.Parameterized.Peano Methods knownRepr :: PeanoRepr Z Source #
KnownRepr BoolRepr 'False Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods knownRepr :: BoolRepr 'False Source #
KnownRepr BoolRepr 'True Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods knownRepr :: BoolRepr 'True Source #
KnownSymbol s => KnownRepr SymbolRepr (s :: Symbol) Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods knownRepr :: SymbolRepr s Source #
KnownRepr PeanoRepr n => KnownRepr PeanoRepr (S n :: Peano) Source # |
Instance details Defined in Data.Parameterized.Peano Methods knownRepr :: PeanoRepr (S n) Source #
KnownRepr (Proxy :: k -> Type) (ctx :: k) Source # |
Instance details Defined in Data.Parameterized.Classes Methods knownRepr :: Proxy ctx Source #
KnownRepr (Assignment f :: Ctx k -> Type) (EmptyCtx :: Ctx k) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods knownRepr :: Assignment f (EmptyCtx :: Ctx k) Source #
KnownRepr (List f :: [k] -> Type) ('[] :: [k]) Source # |
Instance details Defined in Data.Parameterized.List Methods knownRepr :: List f ('[] :: [k]) Source #
(KnownRepr (Assignment f) ctx, KnownRepr f bt) => KnownRepr (Assignment f :: Ctx k -> Type) (ctx ::> bt :: Ctx k) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods knownRepr :: Assignment f (ctx ::> bt) Source #
(KnownRepr f s, KnownRepr (List f) sh) => KnownRepr (List f :: [a] -> Type) (s ': sh :: [a]) Source # |
Instance details Defined in Data.Parameterized.List Methods knownRepr :: List f (s ': sh) Source #

# Re-exports

class Eq a => Hashable a where Source #

The class of types that can be converted to a hash value.

Minimal implementation: `hashWithSalt`.

`Hashable` is intended exclusively for use in in-memory data structures. . `Hashable` does not have a fixed standard. This allows it to improve over time. . Because it does not have a fixed standard, different computers or computers on different versions of the code will observe different hash values. As such, `Hashable` is not recommended for use other than in-memory datastructures. Specifically, `Hashable` is not intended for network use or in applications which persist hashed values. For stable hashing use named hashes: sha256, crc32, xxhash etc.

If you are looking for `Hashable` instance in `time` package, check time-compat

Minimal complete definition

Nothing

Methods

hashWithSalt :: Int -> a -> Int infixl 0 Source #

Return a hash value for the argument, using the given salt.

The general contract of `hashWithSalt` is:

- If two values are equal according to the `==` method, then applying the `hashWithSalt` method on each of the two values must produce the same integer result if the same salt is used in each case.
- It is not required that if two values are unequal according to the `==` method, then applying the `hashWithSalt` method on each of the two values must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal values may improve the performance of hashing-based data structures.
- This method can be used to compute different hash values for the same input by providing a different salt in each application of the method. This implies that any instance that defines `hashWithSalt` must make use of the salt in its implementation.
- `hashWithSalt` may return negative `Int` values.

default hashWithSalt :: (Generic a, GHashable Zero (Rep a)) => Int -> a -> Int Source #

hash :: a -> Int Source #

Like `hashWithSalt`, but no salt is used. The default implementation uses `hashWithSalt` with some default salt. Instances might want to implement this method to provide a more efficient implementation than the default implementation.

#### Instances

Instances details

Hashable ByteArray | This instance was available since 1.4.1.0 only for GHC-9.4+ Since: hashable-1.4.2.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ByteArray -> Int Source # hash :: ByteArray -> Int Source #
Hashable ByteString |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ByteString -> Int Source # hash :: ByteString -> Int Source #
Hashable ByteString |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ByteString -> Int Source # hash :: ByteString -> Int Source #
Hashable ShortByteString |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ShortByteString -> Int Source # hash :: ShortByteString -> Int Source #
Hashable IntSet | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> IntSet -> Int Source # hash :: IntSet -> Int Source #
Hashable BigNat |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> BigNat -> Int Source # hash :: BigNat -> Int Source #
Hashable Void |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Void -> Int Source # hash :: Void -> Int Source #
Hashable ThreadId |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> ThreadId -> Int Source # hash :: ThreadId -> Int Source #
Hashable SomeTypeRep |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> SomeTypeRep -> Int Source # hash :: SomeTypeRep -> Int Source #
Hashable Unique |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Unique -> Int Source # hash :: Unique -> Int Source #
Hashable Version |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Version -> Int Source # hash :: Version -> Int Source #
Hashable Fingerprint | Since: hashable-1.3.0.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Fingerprint -> Int Source # hash :: Fingerprint -> Int Source #
Hashable IntPtr |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> IntPtr -> Int Source # hash :: IntPtr -> Int Source #
Hashable WordPtr |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> WordPtr -> Int Source # hash :: WordPtr -> Int Source #
Hashable Int16 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Int16 -> Int Source # hash :: Int16 -> Int Source #
Hashable Int32 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Int32 -> Int Source # hash :: Int32 -> Int Source #
Hashable Int64 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Int64 -> Int Source # hash :: Int64 -> Int Source #
Hashable Int8 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Int8 -> Int Source # hash :: Int8 -> Int Source #
Hashable Word16 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Word16 -> Int Source # hash :: Word16 -> Int Source #
Hashable Word32 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Word32 -> Int Source # hash :: Word32 -> Int Source #
Hashable Word64 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Word64 -> Int Source # hash :: Word64 -> Int Source #
Hashable Word8 |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Word8 -> Int Source # hash :: Word8 -> Int Source #
Hashable Ordering |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Ordering -> Int Source # hash :: Ordering -> Int Source #
Hashable OsString | Since: hashable-1.4.2.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> OsString -> Int Source # hash :: OsString -> Int Source #
Hashable PosixString | Since: hashable-1.4.2.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> PosixString -> Int Source # hash :: PosixString -> Int Source #
Hashable WindowsString | Since: hashable-1.4.2.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> WindowsString -> Int Source # hash :: WindowsString -> Int Source #
Hashable Text |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Text -> Int Source # hash :: Text -> Int Source #
Hashable Text |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Text -> Int Source # hash :: Text -> Int Source #
Hashable Integer |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Integer -> Int Source # hash :: Integer -> Int Source #
Hashable Natural |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Natural -> Int Source # hash :: Natural -> Int Source #
Hashable () |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> () -> Int Source # hash :: () -> Int Source #
Hashable Bool |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Bool -> Int Source # hash :: Bool -> Int Source #
Hashable Char |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Char -> Int Source # hash :: Char -> Int Source #
Hashable Double | Note: prior to `hashable-1.3.0.0`, `hash 0.0 /= hash (-0.0)` The `hash` of NaN is not well defined. Since: hashable-1.3.0.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Double -> Int Source # hash :: Double -> Int Source #
Hashable Float | Note: prior to `hashable-1.3.0.0`, `hash 0.0 /= hash (-0.0)` The `hash` of NaN is not well defined. Since: hashable-1.3.0.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Float -> Int Source # hash :: Float -> Int Source #
Hashable Int |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Int -> Int Source # hash :: Int -> Int Source #
Hashable Word |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Word -> Int Source # hash :: Word -> Int Source #
Hashable a => Hashable (Complex a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Complex a -> Int Source # hash :: Complex a -> Int Source #
Hashable a => Hashable (First a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> First a -> Int Source # hash :: First a -> Int Source #
Hashable a => Hashable (Last a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Last a -> Int Source # hash :: Last a -> Int Source #
Hashable a => Hashable (Max a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Max a -> Int Source # hash :: Max a -> Int Source #
Hashable a => Hashable (Min a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Min a -> Int Source # hash :: Min a -> Int Source #
Hashable a => Hashable (WrappedMonoid a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> WrappedMonoid a -> Int Source # hash :: WrappedMonoid a -> Int Source #
Hashable v => Hashable (IntMap v) | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> IntMap v -> Int Source # hash :: IntMap v -> Int Source #
Hashable v => Hashable (Seq v) | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Seq v -> Int Source # hash :: Seq v -> Int Source #
Hashable v => Hashable (Set v) | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Set v -> Int Source # hash :: Set v -> Int Source #
Hashable v => Hashable (Tree v) | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Tree v -> Int Source # hash :: Tree v -> Int Source #
Hashable a => Hashable (NonEmpty a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> NonEmpty a -> Int Source # hash :: NonEmpty a -> Int Source #
Hashable a => Hashable (Identity a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Identity a -> Int Source # hash :: Identity a -> Int Source #
Hashable (FunPtr a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> FunPtr a -> Int Source # hash :: FunPtr a -> Int Source #
Hashable (Ptr a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Ptr a -> Int Source # hash :: Ptr a -> Int Source #
Hashable a => Hashable (Ratio a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Ratio a -> Int Source # hash :: Ratio a -> Int Source #
Hashable (StableName a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> StableName a -> Int Source # hash :: StableName a -> Int Source #
Eq a => Hashable (Hashed a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Hashed a -> Int Source # hash :: Hashed a -> Int Source #
Hashable (BoolRepr n) Source # |
Instance details Defined in Data.Parameterized.BoolRepr Methods hashWithSalt :: Int -> BoolRepr n -> Int Source # hash :: BoolRepr n -> Int Source #
Hashable (NatRepr n) Source # |
Instance details Defined in Data.Parameterized.NatRepr.Internal Methods hashWithSalt :: Int -> NatRepr n -> Int Source # hash :: NatRepr n -> Int Source #
Hashable (PeanoRepr n) Source # |
Instance details Defined in Data.Parameterized.Peano Methods hashWithSalt :: Int -> PeanoRepr n -> Int Source # hash :: PeanoRepr n -> Int Source #
Hashable (SymbolRepr nm) Source # |
Instance details Defined in Data.Parameterized.SymbolRepr Methods hashWithSalt :: Int -> SymbolRepr nm -> Int Source # hash :: SymbolRepr nm -> Int Source #
Hashable a => Hashable (Maybe a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Maybe a -> Int Source # hash :: Maybe a -> Int Source #
Hashable a => Hashable (Solo a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Solo a -> Int Source # hash :: Solo a -> Int Source #
Hashable a => Hashable [a] |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> [a] -> Int Source # hash :: [a] -> Int Source #
Hashable (Fixed a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Fixed a -> Int Source # hash :: Fixed a -> Int Source #
Hashable a => Hashable (Arg a b) | Note: Prior to `hashable-1.3.0.0` the hash computation included the second argument of `Arg` which wasn't consistent with its `Eq` instance. Since `hashable-1.5.0.0`, `hash (Semi.arg a _) = hash a` Since: hashable-1.3.0.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Arg a b -> Int Source # hash :: Arg a b -> Int Source #
(Hashable k, Hashable v) => Hashable (Map k v) | Since: hashable-1.3.4.0
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Map k v -> Int Source # hash :: Map k v -> Int Source #
(Hashable a, Hashable b) => Hashable (Either a b) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Either a b -> Int Source # hash :: Either a b -> Int Source #
Hashable (Proxy a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Proxy a -> Int Source # hash :: Proxy a -> Int Source #
Hashable (TypeRep a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> TypeRep a -> Int Source # hash :: TypeRep a -> Int Source #
Hashable (Nonce tp) Source # |
Instance details Defined in Data.Parameterized.Nonce.Unsafe Methods hashWithSalt :: Int -> Nonce tp -> Int Source # hash :: Nonce tp -> Int Source #
(HashableF f, TestEquality f) => Hashable (Some f) Source # |
Instance details Defined in Data.Parameterized.Some Methods hashWithSalt :: Int -> Some f -> Int Source # hash :: Some f -> Int Source #
(Hashable a1, Hashable a2) => Hashable (a1, a2) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2) -> Int Source # hash :: (a1, a2) -> Int Source #
Hashable a => Hashable (Const a b) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Const a b -> Int Source # hash :: Const a b -> Int Source #
(HashableF f, TestEquality f) => Hashable (TypeAp f tp) Source # |
Instance details Defined in Data.Parameterized.Classes Methods hashWithSalt :: Int -> TypeAp f tp -> Int Source # hash :: TypeAp f tp -> Int Source #
(HashableF f, TestEquality f) => Hashable (Assignment f ctx) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods hashWithSalt :: Int -> Assignment f ctx -> Int Source # hash :: Assignment f ctx -> Int Source #
Hashable (Index ctx tp) Source # |
Instance details Defined in Data.Parameterized.Context.Unsafe Methods hashWithSalt :: Int -> Index ctx tp -> Int Source # hash :: Index ctx tp -> Int Source #
Hashable (Index l x) Source # |
Instance details Defined in Data.Parameterized.List Methods hashWithSalt :: Int -> Index l x -> Int Source # hash :: Index l x -> Int Source #
Hashable (Nonce s tp) Source # |
Instance details Defined in Data.Parameterized.Nonce Methods hashWithSalt :: Int -> Nonce s tp -> Int Source # hash :: Nonce s tp -> Int Source #
(Hashable a1, Hashable a2, Hashable a3) => Hashable (a1, a2, a3) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2, a3) -> Int Source # hash :: (a1, a2, a3) -> Int Source #
(Hashable (f a), Hashable (g a)) => Hashable (Product f g a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Product f g a -> Int Source # hash :: Product f g a -> Int Source #
(Hashable (f a), Hashable (g a)) => Hashable (Sum f g a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Sum f g a -> Int Source # hash :: Sum f g a -> Int Source #
(Hashable a1, Hashable a2, Hashable a3, Hashable a4) => Hashable (a1, a2, a3, a4) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2, a3, a4) -> Int Source # hash :: (a1, a2, a3, a4) -> Int Source #
Hashable (f (g a)) => Hashable (Compose f g a) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> Compose f g a -> Int Source # hash :: Compose f g a -> Int Source #
(Hashable a1, Hashable a2, Hashable a3, Hashable a4, Hashable a5) => Hashable (a1, a2, a3, a4, a5) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2, a3, a4, a5) -> Int Source # hash :: (a1, a2, a3, a4, a5) -> Int Source #
(Hashable a1, Hashable a2, Hashable a3, Hashable a4, Hashable a5, Hashable a6) => Hashable (a1, a2, a3, a4, a5, a6) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2, a3, a4, a5, a6) -> Int Source # hash :: (a1, a2, a3, a4, a5, a6) -> Int Source #
(Hashable a1, Hashable a2, Hashable a3, Hashable a4, Hashable a5, Hashable a6, Hashable a7) => Hashable (a1, a2, a3, a4, a5, a6, a7) |
Instance details Defined in Data.Hashable.Class Methods hashWithSalt :: Int -> (a1, a2, a3, a4, a5, a6, a7) -> Int Source # hash :: (a1, a2, a3, a4, a5, a6, a7) -> Int Source #

isJust :: Maybe a -> Bool Source #

The `isJust` function returns `True` iff its argument is of the form `Just _`.

#### Examples

Expand

Basic usage:

    >>> isJust (Just 3)
    True

    >>> isJust (Just ())
    True

    >>> isJust Nothing
    False

Only the outer constructor is taken into consideration:

    >>> isJust (Just Nothing)
    True