th-typegraph-0.32: Graph of the subtype relation

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.TypeGraph.Stack

Contents

Description

The HasStack monad used in MIMO to construct lenses that look deep into a record type. However, it does not involve the Path type mechanism, and is unaware of View instances and other things that modify the type graph. Lets see how it adapts.

Synopsis

Documentation

data TypeStack Source

A stack describes a path from a top type down through fields of its component types.

Constructors

TypeStack 

data StackElement Source

The information required to extact a field value from a value. We keep a stack of these as we traverse a declaration. Generally, we only need the field names.

foldField :: MonadReaders TypeStack m => (FieldType -> m r) -> Dec -> Con -> FieldType -> m r Source

Push the stack and process the field.

Stack+instance map monad

execStackT :: Monad m => StackT m a -> Type -> m a Source

withStack :: (Monad m, MonadReaders TypeStack m) => (TypeStack -> m a) -> m a Source

push :: MonadReaders TypeStack m => FieldType -> Con -> Dec -> m a -> m a Source

push an element onto the TypeStack in m

Stack operations

stackAccessor :: (Quasi m, MonadReaders TypeStack m) => m Exp Source

Return a lambda function that turns a value of Type typ0 into the type implied by the stack elements.

lensNamer :: String -> String Source

Given a field name, return the name to use for the corresponding lens.