th-typegraph-0.14: Graph of the subtype relation

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.TypeGraph.Monad

Synopsis

Documentation

findEdges :: forall m. MonadReader TypeGraphInfo m => m (GraphEdges TypeGraphVertex) Source

Given the discovered set of types and maps of type synonyms and fields, build and return the GraphEdges relation on TypeGraphVertex. This is not a recursive function, it stops when it reaches the field types.

typeVertex :: MonadReader TypeGraphInfo m => E Type -> m TypeGraphVertex Source

Build a TypeGraphVertex from an unexpanded type.

fieldVertex :: MonadReader TypeGraphInfo m => E Type -> (Name, Name, Either Int Name) -> m TypeGraphVertex Source

Build a TypeGraphVertex for a field of a record. This calls typeVertex and then sets the _field value.

typeGraphEdges :: forall m. MonadReader TypeGraphInfo m => m TypeGraphEdges Source

Start with the type graph on the known types with no field information, and build a new graph which incorporates the information from the vertex hints. This means splitting the nodes according to record fields, because hints can refer to particular fields of a record.

typeGraphVertices :: forall m. (DsMonad m, MonadReader TypeGraphInfo m) => m (Set TypeGraphVertex) Source

Return the set of types embedded in the given type. This is just the nodes of the type graph. The type synonymes are expanded by the th-desugar package to make them suitable for use as map keys.

typeGraph :: forall m node key. (DsMonad m, MonadReader TypeGraphInfo m, node ~ TypeGraphVertex, key ~ TypeGraphVertex) => m (Graph, Vertex -> (node, key, [key]), key -> Maybe Vertex) Source

Build a graph from the result of typeGraphEdges, each edge goes from a type to one of the types it contains. Thus, each edge represents a primitive lens, and each path in the graph is a composition of lenses.

simpleEdges :: TypeGraphEdges -> TypeGraphEdges Source

Simplify a graph by throwing away the field information in each node. This means the nodes only contain the fully expanded Type value (and any type synonyms.)

typeSynonymMap :: forall m. (DsMonad m, MonadReader TypeGraphInfo m) => m (Map TypeGraphVertex (Set Name)) Source

Find all the reachable type synonyms and return then in a Map.