Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- data TypeStack = TypeStack {
- _topType :: Type
- _typeStack :: [StackElement]
- topType :: Lens' TypeStack Type
- typeStack :: Lens' TypeStack [StackElement]
- data StackElement = StackElement FieldType Con Dec
- prettyStack :: TypeStack -> String
- foldField :: MonadReaders TypeStack m => (FieldType -> m r) -> Dec -> Con -> FieldType -> m r
- type HasStack = MonadReaders TypeStack
- type StackT m = ReaderT TypeStack m
- execStackT :: Monad m => StackT m a -> Type -> m a
- withStack :: (Monad m, MonadReaders TypeStack m) => (TypeStack -> m a) -> m a
- push :: MonadReaders TypeStack m => FieldType -> Con -> Dec -> m a -> m a
- stackAccessor :: (Quasi m, MonadReaders TypeStack m) => m Exp
- traceIndented :: MonadReaders TypeStack m => String -> m ()
- lensNamer :: String -> String
Documentation
A stack describes a path from a top type down through fields of its component types.
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.
Eq StackElement Source # | |
Data StackElement Source # | |
Show StackElement Source # | |
(Monad m, MonadReaders [StackElement] m) => MonadReaders [StackElement] (ReaderT * TypeGraph m) # | |
prettyStack :: TypeStack -> String Source #
foldField :: MonadReaders TypeStack m => (FieldType -> m r) -> Dec -> Con -> FieldType -> m r Source #
Push the stack and process the field.
Stack+instance map monad
type HasStack = MonadReaders TypeStack 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.
traceIndented :: MonadReaders TypeStack m => String -> m () Source #