Copyright | (c) 2008--2010 Universiteit Utrecht |
---|---|

License | BSD3 |

Maintainer | generics@haskell.org |

Stability | experimental |

Portability | non-portable |

Safe Haskell | Safe |

Language | Haskell2010 |

The definition of functorial map.

## Synopsis

- class HFunctor phi f where
- hmapA :: Applicative a => (forall ix. phi ix -> r ix -> a (r' ix)) -> phi ix -> f r ix -> a (f r' ix)

- hmap :: HFunctor phi f => (forall ix. phi ix -> r ix -> r' ix) -> phi ix -> f r ix -> f r' ix
- hmapM :: (HFunctor phi f, Monad m) => (forall ix. phi ix -> r ix -> m (r' ix)) -> phi ix -> f r ix -> m (f r' ix)

# Generic map

class HFunctor phi f where Source #

hmapA :: Applicative a => (forall ix. phi ix -> r ix -> a (r' ix)) -> phi ix -> f r ix -> a (f r' ix) Source #

## Instances

HFunctor phi U Source # | |

Defined in Generics.MultiRec.HFunctor | |

HFunctor phi (K x) Source # | |

Defined in Generics.MultiRec.HFunctor | |

El phi xi => HFunctor phi (I xi) Source # | |

Defined in Generics.MultiRec.HFunctor | |

(Constructor c, HFunctor phi f) => HFunctor phi (C c f) Source # | |

Defined in Generics.MultiRec.HFunctor | |

(Traversable f, HFunctor phi g) => HFunctor phi (f :.: g) Source # | |

Defined in Generics.MultiRec.HFunctor | |

HFunctor phi f => HFunctor phi (f :>: ix) Source # | |

Defined in Generics.MultiRec.HFunctor | |

(HFunctor phi f, HFunctor phi g) => HFunctor phi (f :*: g) Source # | |

Defined in Generics.MultiRec.HFunctor | |

(HFunctor phi f, HFunctor phi g) => HFunctor phi (f :+: g) Source # | |

Defined in Generics.MultiRec.HFunctor |

hmap :: HFunctor phi f => (forall ix. phi ix -> r ix -> r' ix) -> phi ix -> f r ix -> f r' ix Source #

The function `hmap`

takes a functor `f`

. All the recursive instances
in that functor are wrapped by an application of `r`

. The argument to
`hmap`

takes a function that transformes `r`

occurrences into `r'`

occurrences, for every `ix`

. In order to associate the index `ix`

with the correct family `phi`

, the argument to `hmap`

is additionally
parameterized by a witness of type `phi ix`

.