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

class Monad m => HasStack m where Source

Methods

withStack :: ([StackElement] -> m a) -> m a Source

push :: FieldType -> Con -> Dec -> m a -> m a Source

newtype Wrapper a Source

Constructors

Wrapper a 

Instances

unwrap :: forall a a. Iso (Wrapper a) (Wrapper a) a a 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.

foldField :: HasStack 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 -> m a Source

Stack operations

stackAccessor :: (Quasi m, HasStack m) => ExpQ -> Type -> m Exp Source

Re-implementation of stack accessor in terms of stackLens

makeLenses' :: forall m. (DsMonad m, HasState ExpandMap m) => (Type -> m (Set Type)) -> [Name] -> m [Dec] Source

Generate lenses to access the fields of the row types. Like Control.Lens.TH.makeLenses, but makes lenses for every field, and instead of removing the prefix '_' to form the lens name it adds the prefix "lens" and capitalizes the first letter of the field. The only reason for this function is backwards compatibility, the fields should be changed so they begin with _ and the regular makeLenses should be used.