Hoogle Search

Within LTS Haskell 24.67 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. class GEq (f :: k -> Type)

    some Data.GADT.Compare

    A class for type-contexts which contain enough information to (at least in some cases) decide the equality of types occurring within them. This class is sometimes confused with TestEquality from base. TestEquality only checks type equality. Consider

    >>> data Tag a where TagInt1 :: Tag Int; TagInt2 :: Tag Int
    
    The correct TestEquality Tag instance is
    >>> :{
    instance TestEquality Tag where
    testEquality TagInt1 TagInt1 = Just Refl
    testEquality TagInt1 TagInt2 = Just Refl
    testEquality TagInt2 TagInt1 = Just Refl
    testEquality TagInt2 TagInt2 = Just Refl
    :}
    
    While we can define
    instance GEq Tag where
    geq = testEquality
    
    this will mean we probably want to have
    instance Eq Tag where
    _ == _ = True
    
    Note: In the future version of some package (to be released around GHC-9.6 / 9.8) the forall a. Eq (f a) constraint will be added as a constraint to GEq, with a law relating GEq and Eq:
    geq x y = Just Refl   ⇒  x == y = True        ∀ (x :: f a) (y :: f b)
    x == y                ≡  isJust (geq x y)     ∀ (x, y :: f a)
    
    So, the more useful GEq Tag instance would differentiate between different constructors:
    >>> :{
    instance GEq Tag where
    geq TagInt1 TagInt1 = Just Refl
    geq TagInt1 TagInt2 = Nothing
    geq TagInt2 TagInt1 = Nothing
    geq TagInt2 TagInt2 = Just Refl
    :}
    
    which is consistent with a derived Eq instance for Tag
    >>> deriving instance Eq (Tag a)
    
    Note that even if a ~ b, the geq (x :: f a) (y :: f b) may be Nothing (when value terms are inequal). The consistency of GEq and Eq is easy to check by exhaustion:
    >>> let checkFwdGEq :: (forall a. Eq (f a), GEq f) => f a -> f b -> Bool; checkFwdGEq x y = case geq x y of Just Refl -> x == y; Nothing -> True
    
    >>> (checkFwdGEq TagInt1 TagInt1, checkFwdGEq TagInt1 TagInt2, checkFwdGEq TagInt2 TagInt1, checkFwdGEq TagInt2 TagInt2)
    (True,True,True,True)
    
    >>> let checkBwdGEq :: (Eq (f a), GEq f) => f a -> f a -> Bool; checkBwdGEq x y = if x == y then isJust (geq x y) else isNothing (geq x y)
    
    >>> (checkBwdGEq TagInt1 TagInt1, checkBwdGEq TagInt1 TagInt2, checkBwdGEq TagInt2 TagInt1, checkBwdGEq TagInt2 TagInt2)
    (True,True,True,True)
    

  2. geq :: forall (a :: k) (b :: k) . GEq f => f a -> f b -> Maybe (a :~: b)

    some Data.GADT.Compare

    Produce a witness of type-equality, if one exists. A handy idiom for using this would be to pattern-bind in the Maybe monad, eg.:

    extract :: GEq tag => tag a -> DSum tag -> Maybe a
    extract t1 (t2 :=> x) = do
    Refl <- geq t1 t2
    return x
    
    Or in a list comprehension:
    extractMany :: GEq tag => tag a -> [DSum tag] -> [a]
    extractMany t1 things = [ x | (t2 :=> x) <- things, Refl <- maybeToList (geq t1 t2)]
    
    (Making use of the DSum type from Data.Dependent.Sum in both examples)

  3. module Data.GADT.DeepSeq

    No documentation available.

  4. class HAp h => HSequence (h :: k -> Type -> l -> Type)

    sop-core Data.SOP

    A generalization of sequenceA.

  5. hsequence' :: forall (xs :: l) f (g :: k -> Type) . (HSequence h, SListIN h xs, Applicative f) => h (f :.: g) xs -> f (h g xs)

    sop-core Data.SOP

    Corresponds to sequenceA. Lifts an applicative functor out of a structure. Instances:

    hsequence', sequence'_NP  :: (SListI  xs , Applicative f) => NP  (f :.: g) xs  -> f (NP  g xs )
    hsequence', sequence'_NS  :: (SListI  xs , Applicative f) => NS  (f :.: g) xs  -> f (NS  g xs )
    hsequence', sequence'_POP :: (SListI2 xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)
    hsequence', sequence'_SOP :: (SListI2 xss, Applicative f) => SOP (f :.: g) xss -> f (SOP g xss)
    

  6. class HAp h => HSequence (h :: k -> Type -> l -> Type)

    sop-core Data.SOP.Classes

    A generalization of sequenceA.

  7. hsequence' :: forall (xs :: l) f (g :: k -> Type) . (HSequence h, SListIN h xs, Applicative f) => h (f :.: g) xs -> f (h g xs)

    sop-core Data.SOP.Classes

    Corresponds to sequenceA. Lifts an applicative functor out of a structure. Instances:

    hsequence', sequence'_NP  :: (SListI  xs , Applicative f) => NP  (f :.: g) xs  -> f (NP  g xs )
    hsequence', sequence'_NS  :: (SListI  xs , Applicative f) => NS  (f :.: g) xs  -> f (NS  g xs )
    hsequence', sequence'_POP :: (SListI2 xss, Applicative f) => POP (f :.: g) xss -> f (POP g xss)
    hsequence', sequence'_SOP :: (SListI2 xss, Applicative f) => SOP (f :.: g) xss -> f (SOP g xss)
    

  8. sequence_NP :: forall (xs :: [Type]) f . (SListI xs, Applicative f) => NP f xs -> f (NP I xs)

    sop-core Data.SOP.NP

    Specialization of hsequence. Example:

    >>> sequence_NP (Just 1 :* Just 2 :* Nil)
    Just (I 1 :* I 2 :* Nil)
    

  9. sequence_POP :: forall (xss :: [[Type]]) f . (All (SListI :: [Type] -> Constraint) xss, Applicative f) => POP f xss -> f (POP I xss)

    sop-core Data.SOP.NP

    Specialization of hsequence. Example:

    >>> sequence_POP (POP ((Just 1 :* Nil) :* (Just 2 :* Just 3 :* Nil) :* Nil))
    Just (POP ((I 1 :* Nil) :* (I 2 :* I 3 :* Nil) :* Nil))
    

  10. sequence_NS :: forall (xs :: [Type]) f . (SListI xs, Applicative f) => NS f xs -> f (NS I xs)

    sop-core Data.SOP.NS

    Specialization of hsequence.

Page 292 of many | Previous | Next