Safe Haskell | Safe |
---|---|
Language | Haskell98 |
DDC.Core.Exp.Annot.Compounds
Description
Utilities for constructing and destructing compound expressions.
For the annotated version of the AST.
- module DDC.Type.Compounds
- annotOfExp :: Exp a n -> a
- mapAnnotOfExp :: (a -> a) -> Exp a n -> Exp a n
- xLAMs :: a -> [Bind n] -> Exp a n -> Exp a n
- xLams :: a -> [Bind n] -> Exp a n -> Exp a n
- makeXLamFlags :: a -> [(Bool, Bind n)] -> Exp a n -> Exp a n
- takeXLAMs :: Exp a n -> Maybe ([Bind n], Exp a n)
- takeXLams :: Exp a n -> Maybe ([Bind n], Exp a n)
- takeXLamFlags :: Exp a n -> Maybe ([(Bool, Bind n)], Exp a n)
- data Param n
- = ParamType (Bind n)
- | ParamValue (Bind n)
- | ParamBox
- takeXLamParam :: Exp a n -> Maybe ([Param n], Exp a n)
- xApps :: a -> Exp a n -> [Exp a n] -> Exp a n
- makeXAppsWithAnnots :: Exp a n -> [(Exp a n, a)] -> Exp a n
- takeXApps :: Exp a n -> Maybe (Exp a n, [Exp a n])
- takeXApps1 :: Exp a n -> Exp a n -> (Exp a n, [Exp a n])
- takeXAppsAsList :: Exp a n -> [Exp a n]
- takeXAppsWithAnnots :: Exp a n -> (Exp a n, [(Exp a n, a)])
- takeXConApps :: Exp a n -> Maybe (DaCon n, [Exp a n])
- takeXPrimApps :: Exp a n -> Maybe (n, [Exp a n])
- xLets :: a -> [Lets a n] -> Exp a n -> Exp a n
- xLetsAnnot :: [(Lets a n, a)] -> Exp a n -> Exp a n
- splitXLets :: Exp a n -> ([Lets a n], Exp a n)
- splitXLetsAnnot :: Exp a n -> ([(Lets a n, a)], Exp a n)
- bindsOfLets :: Lets a n -> ([Bind n], [Bind n])
- specBindsOfLets :: Lets a n -> [Bind n]
- valwitBindsOfLets :: Lets a n -> [Bind n]
- patOfAlt :: Alt a n -> Pat n
- takeCtorNameOfAlt :: Alt a n -> Maybe n
- bindsOfPat :: Pat n -> [Bind n]
- makeRuns :: a -> Int -> Exp a n -> Exp a n
- wApp :: a -> Witness a n -> Witness a n -> Witness a n
- wApps :: a -> Witness a n -> [Witness a n] -> Witness a n
- annotOfWitness :: Witness a n -> a
- takeXWitness :: Exp a n -> Maybe (Witness a n)
- takeWAppsAsList :: Witness a n -> [Witness a n]
- takePrimWiConApps :: Witness a n -> Maybe (n, [Witness a n])
- takeXType :: Exp a n -> Maybe (Type n)
- xUnit :: a -> Exp a n
- dcUnit :: DaCon n
- takeNameOfDaCon :: DaCon n -> Maybe n
- takeTypeOfDaCon :: DaCon n -> Maybe (Type n)
Documentation
module DDC.Type.Compounds
Annotations
annotOfExp :: Exp a n -> a Source
Take the outermost annotation from an expression.
mapAnnotOfExp :: (a -> a) -> Exp a n -> Exp a n Source
Apply a function to the annotation of an expression.
Lambdas
makeXLamFlags :: a -> [(Bool, Bind n)] -> Exp a n -> Exp a n Source
Make some nested lambda abstractions, using a flag to indicate whether the lambda is a level-1 (True), or level-0 (False) binder.
takeXLAMs :: Exp a n -> Maybe ([Bind n], Exp a n) Source
Split type lambdas from the front of an expression,
or Nothing
if there aren't any.
takeXLams :: Exp a n -> Maybe ([Bind n], Exp a n) Source
Split nested value or witness lambdas from the front of an expression,
or Nothing
if there aren't any.
takeXLamFlags :: Exp a n -> Maybe ([(Bool, Bind n)], Exp a n) Source
Split nested lambdas from the front of an expression, with a flag indicating whether the lambda was a level-1 (True), or level-0 (False) binder.
Parameters of a function.
Constructors
ParamType (Bind n) | |
ParamValue (Bind n) | |
ParamBox |
Applications
makeXAppsWithAnnots :: Exp a n -> [(Exp a n, a)] -> Exp a n Source
takeXApps :: Exp a n -> Maybe (Exp a n, [Exp a n]) Source
Flatten an application into the function part and its arguments.
Returns Nothing
if there is no outer application.
takeXApps1 :: Exp a n -> Exp a n -> (Exp a n, [Exp a n]) Source
Flatten an application into the function part and its arguments.
This is like takeXApps
above, except we know there is at least one argument.
takeXAppsAsList :: Exp a n -> [Exp a n] Source
Flatten an application into the function parts and arguments, if any.
takeXAppsWithAnnots :: Exp a n -> (Exp a n, [(Exp a n, a)]) Source
Destruct sequence of applications.
Similar to takeXAppsAsList
but also keeps annotations for later.
takeXConApps :: Exp a n -> Maybe (DaCon n, [Exp a n]) Source
Flatten an application of a data constructor into the constructor and its arguments.
Returns Nothing
if the expression isn't a constructor application.
takeXPrimApps :: Exp a n -> Maybe (n, [Exp a n]) Source
Flatten an application of a primop into the variable and its arguments.
Returns Nothing
if the expression isn't a primop application.
Lets
xLetsAnnot :: [(Lets a n, a)] -> Exp a n -> Exp a n Source
Wrap some let-bindings around an expression, with individual annotations.
splitXLets :: Exp a n -> ([Lets a n], Exp a n) Source
Split let-bindings from the front of an expression, if any.
splitXLetsAnnot :: Exp a n -> ([(Lets a n, a)], Exp a n) Source
Split let-bindings from the front of an expression, with annotations.
bindsOfLets :: Lets a n -> ([Bind n], [Bind n]) Source
Take the binds of a Lets
.
The level-1 and level-0 binders are returned separately.
specBindsOfLets :: Lets a n -> [Bind n] Source
Like bindsOfLets
but only take the spec (level-1) binders.
valwitBindsOfLets :: Lets a n -> [Bind n] Source
Like bindsOfLets
but only take the value and witness (level-0) binders.
Alternatives
takeCtorNameOfAlt :: Alt a n -> Maybe n Source
Take the constructor name of an alternative, if there is one.
Patterns
bindsOfPat :: Pat n -> [Bind n] Source
Take the binds of a Pat
.
Casts
makeRuns :: a -> Int -> Exp a n -> Exp a n Source
Wrap an expression in the given number of run
casts.
Witnesses
wApps :: a -> Witness a n -> [Witness a n] -> Witness a n Source
Construct a sequence of witness applications
annotOfWitness :: Witness a n -> a Source
Take the annotation from a witness.
takeXWitness :: Exp a n -> Maybe (Witness a n) Source
Take the witness from an XWitness
argument, if any.
takeWAppsAsList :: Witness a n -> [Witness a n] Source
Flatten an application into the function parts and arguments, if any.
takePrimWiConApps :: Witness a n -> Maybe (n, [Witness a n]) Source
Flatten an application of a witness into the witness constructor name and its arguments.
Returns nothing if there is no witness constructor in head position.
Types
Data Constructors
takeNameOfDaCon :: DaCon n -> Maybe n Source
Take the name of data constructor, if there is one.
takeTypeOfDaCon :: DaCon n -> Maybe (Type n) Source
Take the type annotation of a data constructor, if we know it locally.