ddc-source-tetra-0.4.1.1: Disciplined Disciple Compiler source language.

Safe HaskellSafe-Inferred

DDC.Source.Tetra.Compounds

Contents

Synopsis

Documentation

takeAnnotOfExp :: Exp a n -> Maybe aSource

Take the outermost annotation from an expression, or Nothing if this is an XType or XWitness without an annotation.

Lambdas

xLAMs :: a -> [Bind n] -> Exp a n -> Exp a nSource

Make some nested type lambdas.

xLams :: a -> [Bind n] -> Exp a n -> Exp a nSource

Make some nested value or witness lambdas.

makeXLamFlags :: a -> [(Bool, Bind n)] -> Exp a n -> Exp a nSource

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.

Applications

xApps :: a -> Exp a n -> [Exp a n] -> Exp a nSource

Build sequence of value applications.

makeXAppsWithAnnots :: Exp a n -> [(Exp a n, a)] -> Exp a nSource

Build sequence of applications. Similar to xApps but also takes list of annotations for the XApp constructors.

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.

Data Constructors

dcUnit :: DaCon n

The unit data constructor.

takeNameOfDaCon :: DaCon n -> Maybe n

Take the name of data constructor, if there is one.

takeTypeOfDaCon :: DaCon n -> Maybe (Type n)

Take the type annotation of a data constructor, if we know it locally.

Patterns

bindsOfPat :: Pat n -> [Bind n]

Take the binds of a Pat.

Witnesses

wApp :: a -> Witness a n -> Witness a n -> Witness a n

Construct a witness application

wApps :: a -> Witness a n -> [Witness a n] -> Witness a n

Construct a sequence of witness applications

takeXWitness :: Exp a n -> Maybe (Witness a n)

Take the witness from an XWitness argument, if any.

takeWAppsAsList :: Witness a n -> [Witness a n]

Flatten an application into the function parts and arguments, if any.

takePrimWiConApps :: Witness a n -> Maybe (n, [Witness a n])

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.