dualizer-0.1.0.1: Automatically generate dual constructions.

Safe HaskellNone
LanguageHaskell2010

Categorical.Dual

Description

Operations to connect dual constructions.

Synopsis

Documentation

importDuals :: Q DualMappings -> Q [Dec] Source #

Imports duals from other modules via the var created by exportDuals in that other module.

exportDuals :: String -> Q [Dec] Source #

Creates a value that can be referenced in other modules to load the duals defined in this module. Should be used at the bottom of any module that uses this module.

emptyDuals :: Q DualMappings Source #

The empty set of duals, should only be used to initalize the duals for Prelude.

dualType :: Type -> Q Type Source #

Returns a type that is the dual of the input type.

dualExp :: Exp -> Q Exp Source #

Convert an expression to its dual (i.e., an implementation for the dual of the input expression’s type)

makeDualClass :: Name -> String -> [(Name, String)] -> Q [Dec] Source #

Given a class, creates a new class that represents its dual, with the list containing name mappings of methods to their duals.

makeDualDec :: Q [Dec] -> String -> Q [Dec] Source #

Creates both the original declaration and its dual. Should only work for declarations that introduce exactly one top-level name.

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

Indicate that two names are duals of each other.

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

Indicates that some name represents the dual of itself (e.g., Functor).

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

This provides a mapping one way, but not the other. Useful for aliased functions (return) and overconstrained versions (e.g., mapping `traverse ↔ distribute` but also `mapM → distribute`).