Copyright | License : BSD3 |
---|---|
Maintainer | The Idris Community. |
Safe Haskell | None |
Language | Haskell2010 |
This implements just a few basic lens-like concepts to ease state updates. Similar to fclabels in approach, just without the extra dependency.
We don't include an explicit export list because everything here is meant to be exported.
Short synopsis: --------------- @ f :: Idris () f = do -- these two steps: detaggable <- fgetState (opt_detaggable . ist_optimisation typeName) fputState (opt_detaggable . ist_optimisation typeName) (not detaggable)
- - are equivalent to: fmodifyState (opt_detaggable . ist_optimisation typeName) not
- - of course, the long accessor can be put in a variable;
- - everything is first-class let detag n = opt_detaggable . ist_optimisation n fputState (detag n1) True fputState (detag n2) False
- - Note that all these operations handle missing items consistently
- - and transparently, as prescribed by the default values included
- - in the definitions of the ist_* functions.
- -
- - Especially, it's no longer necessary to have initial values of
- - data structures copied (possibly inconsistently) all over the compiler. @
- data Field rec fld
- cg_usedpos :: Field CGInfo [(Int, [UsageReason])]
- ctxt_lookup :: Name -> Field (Ctxt a) (Maybe a)
- fgetState :: MonadState s m => Field s a -> m a
- fmodifyState :: MonadState s m => Field s a -> (a -> a) -> m ()
- fputState :: MonadState s m => Field s a -> a -> m ()
- idris_fixities :: Field IState [FixDecl]
- ist_callgraph :: Name -> Field IState CGInfo
- ist_optimisation :: Name -> Field IState OptInfo
- known_interfaces :: Field IState (Ctxt InterfaceInfo)
- known_terms :: Field IState (Ctxt (Def, RigCount, Injectivity, Accessibility, Totality, MetaInformation))
- opt_detaggable :: Field OptInfo Bool
- opt_inaccessible :: Field OptInfo [(Int, Name)]
- opt_forceable :: Field OptInfo [Int]
- opts_idrisCmdline :: Field IState [Opt]
- repl_definitions :: Field IState [Name]
Documentation
cg_usedpos :: Field CGInfo [(Int, [UsageReason])] Source #
ctxt_lookup :: Name -> Field (Ctxt a) (Maybe a) Source #
Exact-name context lookup; uses Nothing for deleted values (read+write!).
Reading a non-existing value yields Nothing, writing Nothing deletes the value (if it existed).
fgetState :: MonadState s m => Field s a -> m a Source #
fmodifyState :: MonadState s m => Field s a -> (a -> a) -> m () Source #
fputState :: MonadState s m => Field s a -> a -> m () Source #
ist_optimisation :: Name -> Field IState OptInfo Source #
the optimisation record for the given (exact) name
known_terms :: Field IState (Ctxt (Def, RigCount, Injectivity, Accessibility, Totality, MetaInformation)) Source #
TT Context
This has a terrible name, but I'm not sure of a better one that isn't confusingly close to tt_ctxt