ddc-core-0.2.0.1: Disciple Core language and type checker.

Safe HaskellSafe-Infered

DDC.Core.Compounds

Contents

Description

Utilities for constructing and destructing compound expressions.

Synopsis

Lets

bindsOfLets :: Lets a n -> [Bind n]Source

Take the binds of a Lets.

specBindsOfLets :: Lets a n -> [Bind n]Source

Like bindsOfLets but only take the type binders.

valwitBindsOfLets :: Lets a n -> [Bind n]Source

Like bindsOfLets but only take the value and witness binders.

Patterns

bindsOfPat :: Pat n -> [Bind n]Source

Take the binds of a Pat.

Lambdas

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

Make some nested type lambda abstractions.

takeXLAMs :: Exp a n -> Maybe ([Bind n], Exp a n)Source

Split nested value and witness lambdas from the front of an expression, or Nothing if there aren't any.

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

Make some nested value or witness lambda abstractions.

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.

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.

Applications

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

Build sequence of type applications.

takeXApps :: Exp a n -> [Exp a n]Source

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

takeXConApps :: Exp a n -> Maybe (Bound 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.

Alternatives

takeCtorNameOfAlt :: Alt a n -> Maybe nSource

Take the constructor name of an alternative, if there is one.