Idris.ASTUtils

idris-1.3.4: Functional Programming Language with Dependent Types

License | BSD3
Maintainer | The Idris Community.
Safe Haskell | None
Language | Haskell2010

Idris.ASTUtils

Description

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. @

Synopsis

- 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

data Field rec fld #

#### Instances

Instances details

Category Field # |
Instance details Defined in Idris.ASTUtils Methods id :: Field a a # (.) :: Field b c -> Field a b -> Field a c #

cg_usedpos :: Field CGInfo [(Int, [UsageReason])] #

ctxt_lookup :: Name -> Field (Ctxt a) (Maybe a) #

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 #

fmodifyState :: MonadState s m => Field s a -> (a -> a) -> m () #

fputState :: MonadState s m => Field s a -> a -> m () #

idris_fixities :: Field IState [FixDecl] #

Fixity declarations in an IState

ist_callgraph :: Name -> Field IState CGInfo #

callgraph record for the given (exact) name

ist_optimisation :: Name -> Field IState OptInfo #

the optimisation record for the given (exact) name

known_interfaces :: Field IState (Ctxt InterfaceInfo) #

known_terms :: Field IState (Ctxt (Def, RigCount, Injectivity, Accessibility, Totality, MetaInformation)) #

TT Context

This has a terrible name, but I'm not sure of a better one that isn't confusingly close to tt_ctxt

opt_detaggable :: Field OptInfo Bool #

opt_inaccessible :: Field OptInfo [(Int, Name)] #

two fields of the optimisation record

opt_forceable :: Field OptInfo [Int] #

opts_idrisCmdline :: Field IState [Opt] #

Commandline flags

repl_definitions :: Field IState [Name] #

Names defined at the repl