parsley-core-2.3.0.0: A fast parser combinator library backed by Typed Template Haskell
LicenseBSD-3-Clause
MaintainerJamie Willis
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Parsley.Internal.Core.Lam

Description

This module contains Lam, which is a defunctionalised lambda calculus. This serves as a more easy to work with form of defunctionalisation moving into the backend and machine where it is no longer necessary to inspect function values. It permits for the generation of efficient terms, with some inspection of values.

Since: 1.0.1.0

Synopsis

Documentation

normaliseGen :: (?flags :: Flags) => Lam a -> Code a Source #

Generates Haskell code that represents a Lam value, but normalising it first to ensure the term is minimal.

Since: 1.0.1.0

normalise :: (?flags :: Flags) => Lam a -> Lam a Source #

Optimises a Lam expression, reducing it until the outmost lambda, let, or if statement.

Since: 1.0.1.0

data Lam a where Source #

Defunctionalised lambda calculus in HOAS form. Supports basic inspection of values, but not functions.

Since: 1.0.1.0

Constructors

Abs :: (Lam a -> Lam b) -> Lam (a -> b)

Function abstraction.

App :: Lam (a -> b) -> Lam a -> Lam b

Function application.

Var :: Bool -> Code a -> Lam a

Variable. The boolean represents whether it is "simple" or "complex", i.e. the size of the term.

If :: Lam Bool -> Lam a -> Lam a -> Lam a

Conditional expression.

Let :: Lam a -> (Lam a -> Lam b) -> Lam b

Let-binding.

T :: Lam Bool

Value representing true.

F :: Lam Bool

Value representing false.

Instances

Instances details
Show (Lam a) Source # 
Instance details

Defined in Parsley.Internal.Core.Lam

Methods

showsPrec :: Int -> Lam a -> ShowS #

show :: Lam a -> String #

showList :: [Lam a] -> ShowS #