data-effects-th-0.4.2.1: Template Haskell utilities for the data-effects library.
Copyright(c) 2023 Sayo contributors
LicenseMPL-2.0 (see the file LICENSE)
Maintainerymdfield@outlook.jp
Safe HaskellNone
LanguageGHC2021

Data.Effect.HFunctor.TH

Description

This module provides TemplateHaskell functions to derive an instance of HFunctor.

Synopsis

Documentation

makeHFunctor :: Name -> Q [Dec] Source #

Derive an instance of HFunctor for a type constructor of any higher-order kind taking at least two arguments.

makeHFunctor' :: Name -> (Infinite (Q Type) -> Q Type) -> Q [Dec] Source #

Derive an instance of HFunctor for a type constructor of any higher-order kind taking at least two arguments.

Furthermore, you can manually provide type constraints for the instance:

{-# LANGUAGE BlockArguments #-}
import Data.List.Infinite (Infinite ((:<)))

data Example (g :: Type -> Type) h (f :: Type -> Type) (a :: Type) where
    Example :: g (h f a) -> Example g h f a

makeHFunctor' ''Example \(g :< h :< _) -> [t| (Functor $g, HFunctor $h) |]

data Infinite a #

Type of infinite lists.

In terms of recursion schemes, Infinite a is a fix point of the base functor (a,), foldr is a catamorphism and unfoldr is an anamorphism.

Constructors

a :< (Infinite a) infixr 5