Copyright | (c) Justin Le 2018 |
---|---|

License | BSD3 |

Maintainer | justin@jle.im |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell2010 |

Generalize Data.Vinyl.XRec: provides a version of products in Data.Type.Functor.Product that "erases" newtype wrappers and other syntactical noise.

Data.Type.Functor.Product is the "main functionality", but this module
provides an alternative interface that may be more convenient in some
situations, in the same way that `XRec`

can be more convenient than
`Rec`

in some situations.

## Synopsis

- type XProd f g = Prod f (XData g) :: f k -> Type
- fromXProd :: forall f g as. (FProd f, PureProdC f (IsoHKD g) as) => XProd f g as -> Prod f g as
- toXProd :: forall f g as. (FProd f, PureProdC f (IsoHKD g) as) => Prod f g as -> XProd f g as
- mapProdX :: forall f g h as. FProd f => (forall a. HKD g a -> HKD h a) -> XProd f g as -> XProd f h as
- mapProdXEndo :: forall f g as. FProd f => (forall a. HKD g a -> HKD g a) -> XProd f g as -> XProd f g as
- imapProdX :: forall f g h as. FProd f => (forall a. Elem f as a -> HKD g a -> HKD h a) -> XProd f g as -> XProd f h as
- zipWithProdX :: forall f g h j as. FProd f => (forall a. HKD g a -> HKD h a -> HKD j a) -> XProd f g as -> XProd f h as -> XProd f j as
- ixProdX :: FProd f => Elem f as a -> Lens' (XProd f g as) (HKD g a)
- traverseProdX :: forall f g h m as. (FProd f, Applicative m) => (forall a. HKD g a -> m (HKD h a)) -> XProd f g as -> m (XProd f h as)
- traverseProdXEndo :: forall f g m as. (FProd f, Applicative m) => (forall a. HKD g a -> m (HKD g a)) -> XProd f g as -> m (XProd f g as)
- itraverseProdX :: forall f g h m as. (FProd f, Applicative m) => (forall a. Elem f as a -> HKD g a -> m (HKD h a)) -> XProd f g as -> m (XProd f h as)
- foldMapProdX :: forall f g m as. (FProd f, Monoid m) => (forall a. HKD g a -> m) -> XProd f g as -> m
- ifoldMapProdX :: forall f g m as. (FProd f, Monoid m) => (forall a. Elem f as a -> HKD g a -> m) -> XProd f g as -> m
- type XRec (f :: u -> Type) = Rec (XData f)
- pattern (::&) :: forall a (f :: a -> Type) (r :: a) rs. HKD f r -> XRec f rs -> XRec f (r ': rs)
- pattern XRNil :: forall u (f :: u -> Type). XRec f ('[] :: [u])
- type XMaybe f = PMaybe (XData f)
- pattern XNothing :: XMaybe f 'Nothing
- pattern XJust :: HKD f a -> XMaybe f ('Just a)
- type XEither f = PEither (XData f)
- pattern XLeft :: Sing e -> XEither f ('Left e)
- pattern XRight :: HKD f a -> XEither f ('Right a)
- type XNERec f = NERec (XData f)
- pattern (::&|) :: HKD f a -> XRec f as -> XNERec f (a :| as)
- type XTup f = PTup (XData f)
- pattern XTup :: Sing w -> HKD f a -> XTup f '(w, a)
- type XIdentity f = PIdentity (XData f)
- pattern XIdentity :: HKD f a -> XIdentity f ('Identity a)

# Documentation

fromXProd :: forall f g as. (FProd f, PureProdC f (IsoHKD g) as) => XProd f g as -> Prod f g as Source #

toXProd :: forall f g as. (FProd f, PureProdC f (IsoHKD g) as) => Prod f g as -> XProd f g as Source #

# Functions

mapProdX :: forall f g h as. FProd f => (forall a. HKD g a -> HKD h a) -> XProd f g as -> XProd f h as Source #

mapProdXEndo :: forall f g as. FProd f => (forall a. HKD g a -> HKD g a) -> XProd f g as -> XProd f g as Source #

imapProdX :: forall f g h as. FProd f => (forall a. Elem f as a -> HKD g a -> HKD h a) -> XProd f g as -> XProd f h as Source #

zipWithProdX :: forall f g h j as. FProd f => (forall a. HKD g a -> HKD h a -> HKD j a) -> XProd f g as -> XProd f h as -> XProd f j as Source #

ixProdX :: FProd f => Elem f as a -> Lens' (XProd f g as) (HKD g a) Source #

Given an index into an `XProd`

, provides a lens into the simplified
item that that index points to.

traverseProdX :: forall f g h m as. (FProd f, Applicative m) => (forall a. HKD g a -> m (HKD h a)) -> XProd f g as -> m (XProd f h as) Source #

Convenient wrapper over `traverseProd`

that lets you deal with the
"simplified" inner types.

traverseProdXEndo :: forall f g m as. (FProd f, Applicative m) => (forall a. HKD g a -> m (HKD g a)) -> XProd f g as -> m (XProd f g as) Source #

A version of `traverseProdX`

that doesn't change the context `g`

; this can
be easier for type inference in some situations.

itraverseProdX :: forall f g h m as. (FProd f, Applicative m) => (forall a. Elem f as a -> HKD g a -> m (HKD h a)) -> XProd f g as -> m (XProd f h as) Source #

A version of `traverseProdX`

that passes along the index `Elem`

with
each value. This can help with type inference in some situations.

foldMapProdX :: forall f g m as. (FProd f, Monoid m) => (forall a. HKD g a -> m) -> XProd f g as -> m Source #

Convenient wrapper over `foldMapProd`

that lets you deal with the
"simplified" inner types.

ifoldMapProdX :: forall f g m as. (FProd f, Monoid m) => (forall a. Elem f as a -> HKD g a -> m) -> XProd f g as -> m Source #

A version of `foldMapProdX`

that passes along the index `Elem`

with
each value. This can help with type inference in some situations.

# Instances

pattern (::&) :: forall a (f :: a -> Type) (r :: a) rs. HKD f r -> XRec f rs -> XRec f (r ': rs) infixr 7 #