th-typegraph-0.35.1: 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 

Instances

Eq TypeStack Source # 
Data TypeStack Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TypeStack -> c TypeStack #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TypeStack #

toConstr :: TypeStack -> Constr #

dataTypeOf :: TypeStack -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TypeStack) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TypeStack) #

gmapT :: (forall b. Data b => b -> b) -> TypeStack -> TypeStack #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TypeStack -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TypeStack -> r #

gmapQ :: (forall d. Data d => d -> u) -> TypeStack -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TypeStack -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TypeStack -> m TypeStack #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeStack -> m TypeStack #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TypeStack -> m TypeStack #

Show TypeStack Source # 
MonadReaders TypeInfo m => MonadReaders TypeInfo (ReaderT * TypeStack m) Source # 

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.

Instances

Eq StackElement Source # 
Data StackElement Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StackElement -> c StackElement #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StackElement #

toConstr :: StackElement -> Constr #

dataTypeOf :: StackElement -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c StackElement) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StackElement) #

gmapT :: (forall b. Data b => b -> b) -> StackElement -> StackElement #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StackElement -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StackElement -> r #

gmapQ :: (forall d. Data d => d -> u) -> StackElement -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> StackElement -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> StackElement -> m StackElement #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StackElement -> m StackElement #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StackElement -> m StackElement #

Show StackElement Source # 
(Monad m, MonadReaders [StackElement] m) => MonadReaders [StackElement] (ReaderT * TypeGraph m) # 

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.