Hoogle Search

Within LTS Haskell 24.68 (ghc-9.10.3)

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

  1. gatheredN1MapRec :: forall f a (as :: [Type]) b . Inplicative f => (XRec Identity (a ': as) -> b) -> (b -> XRec Identity (a ': as)) -> Rec f (a ': as) -> f b

    functor-combinators Data.Functor.Invariant.Inplicative

    A version of gatheredNMap using XRec from vinyl instead of NP from sop-core. This can be more convenient because it doesn't require manual unwrapping/wrapping of tuple components.

  2. gatheredNMap :: forall f (as :: [Type]) b . Inplicative f => (NP I as -> b) -> (b -> NP I as) -> NP f as -> f b

    functor-combinators Data.Functor.Invariant.Inplicative

    Given a function to "break out" a data type into a NP (tuple) and one to put it back together from the tuple, gather all of the components together. For example, if you had a data type

    data MyType = MT Int Bool String
    
    and an invariant functor and Inplicative instance Prim (representing, say, a bidirectional parser, where Prim Int is a bidirectional parser for an Int), then you could assemble a bidirectional parser for a MyType@ using:
    concaMapInplicative
    ((MyType x y z) -> I x :* I y :* I z :* Nil)
    ((I x :* I y :* I z :* Nil) -> MyType x y z)
    $ intPrim
    :* boolPrim
    :* stringPrim
    :* Nil
    
    See notes on gatheredNMap for more details and caveats.

  3. gatheredNMapRec :: forall f (as :: [Type]) b . Inplicative f => (XRec Identity as -> b) -> (b -> XRec Identity as) -> Rec f as -> f b

    functor-combinators Data.Functor.Invariant.Inplicative

    A version of gatheredNMap using XRec from vinyl instead of NP from sop-core. This can be more convenient because it doesn't require manual unwrapping/wrapping of tuple components.

  4. swervedN1Map :: forall f a (as :: [Type]) b . Inalt f => (NS I (a ': as) -> b) -> (b -> NS I (a ': as)) -> NP f (a ': as) -> f b

    functor-combinators Data.Functor.Invariant.Internative

    A version of swervedNMap for non-empty NS, but only requiring an Inalt instance.

  5. swervedNMap :: forall f (as :: [Type]) b . Inplus f => (NS I as -> b) -> (b -> NS I as) -> NP f as -> f b

    functor-combinators Data.Functor.Invariant.Internative

    Given a function to "discern out" a data type into possible NS (multi-way Either) branches and one to re-assemble each brann, swerve all of the components together. For example, if you had a data type

    data MyType = MTI Int | MTB Bool | MTS String
    
    and an invariant functor and Inplus instance Prim (representing, say, a bidirectional parser, where Prim Int is a bidirectional parser for an Int), then you could assemble a bidirectional parser for a MyType@ using:
    swervedNMap
    (case MTI x -> Z (I x); MTB y -> S (Z (I y)); MTS z -> S (S (Z (I z))))
    (case Z (I x) -> MTI x; S (Z (I y)) -> MTB y; S (S (Z (I z))) -> MTS z) $
    $ intPrim
    :* boolPrim
    :* stringPrim
    :* Nil
    
    Some notes on usefulness depending on how many components you have:
    • If you have 0 components, use reject directly.
    • If you have 1 component, you don't need anything.
    • If you have 2 components, use swerve directly.
    • If you have 3 or more components, these combinators may be useful; otherwise you'd need to manually peel off eithers one-by-one.
    See notes on swervedNMap for more details and caveats.

  6. hbimap :: forall (f :: k -> Type) (j :: k -> Type) (g :: k -> Type) (l :: k -> Type) . HBifunctor t => (f ~> j) -> (g ~> l) -> t f g ~> t j l

    functor-combinators Data.HBifunctor

    Swap out both transformed functors at the same time.

  7. hmap :: forall (f :: k -> Type) (g :: k -> Type) . HFunctor t => (f ~> g) -> t f ~> t g

    functor-combinators Data.HFunctor

    If we can turn an f into a g, then we can turn a t f into a t g. It must be the case that

    hmap id == id
    
    Essentially, t f adds some "extra structure" to f. hmap must swap out the functor, without affecting the added structure. For example, ListF f a is essentially a list of f as. If we hmap to swap out the f as for g as, then we must ensure that the "added structure" (here, the number of items in the list, and the ordering of those items) remains the same. So, hmap must preserve the number of items in the list, and must maintain the ordering. The law hmap id == id is a way of formalizing this property.

  8. injectContramap :: (Inject t, Contravariant f) => (a -> b) -> f b -> t f a

    functor-combinators Data.HFunctor

    A useful wrapper over the common pattern of contramap-before-inject/inject-and-contramap.

  9. injectMap :: (Inject t, Functor f) => (a -> b) -> f a -> t f b

    functor-combinators Data.HFunctor

    A useful wrapper over the common pattern of fmap-before-inject/inject-and-fmap.

  10. foldMapSing :: forall (f :: Type -> Type) k (as :: f k) m . (FProd f, Monoid m) => (forall (a :: k) . () => Sing a -> m) -> Sing as -> m

    functor-products Data.Type.Functor.Product

    A foldMap over all items in a collection.

Page 1034 of many | Previous | Next