Tracing

Definitions to support evaluation tracing of functional programs in Python.

Copyright (c) 2024 - Eindhoven University of Technology, The Netherlands

This software is made available under the terms of the MIT License.

class FuPy.tracing.BaseStep(note: str, depth: int = 0)[source]

Bases: ABC

Abstract Base Class for all Trace steps.

depth: int = 0
note: str
set_depth(depth: int) BaseStep[source]

Set the depth of the step.

class FuPy.tracing.Trace(trace: list[~FuPy.tracing.BaseStep] = <factory>, depth: int = 0, skip_steps: set[type[~FuPy.tracing.BaseStep]] = <factory>, max_steps: int = None)[source]

Bases: object

A Trace object contains a sequence of evaluation (rewrite) steps.

depth: int = 0
log(step: BaseStep) None[source]

Append a step to the trace.

max_steps: int = None
skip_steps: set[type[BaseStep]]
trace: list[BaseStep]
update_depth(delta: int) None[source]

Update the depth for the next step.

exception FuPy.tracing.TracingTerminated[source]

Bases: Exception

Exception to indicate early termination of an expression evaluation.

Typically, this is because the maximum number of steps was reached.

FuPy.tracing.dec_depth() None[source]

Decrement the tracing depth by one.

FuPy.tracing.inc_depth() None[source]

Increment the tracing depth by one.

FuPy.tracing.trace(expr: Callable[[], A], live: bool | None = None, skip_steps: set[type[BaseStep]] | None = None, max_steps: int | None = None) tuple[A | Exception, Trace][source]

Trace evaluation of expr. The expression must be provided as a constant function, that is, in the form lambda: expr, or as Lazy(lambda: expr). Later, possibly also as string.

FuPy.tracing.trace_step(step_: Callable[[], BaseStep]) None[source]

Add step_() to the trace if tracing is enabled. For internal use only.

Tracing basics

Definitions to support evaluation tracing of basic functionality.

Copyright (c) 2024 - Eindhoven University of Technology, The Netherlands

This software is made available under the terms of the MIT License.

class FuPy.tracing_basics.ApplicationStep(note: str)[source]

Bases: BaseStep

Class for function application steps.

class FuPy.tracing_basics.DefinitionStep(note: str)[source]

Bases: BaseStep

Class for function construction steps.

class FuPy.tracing_basics.MotivationStep(note: str)[source]

Bases: BaseStep

Class for motivation steps.

class FuPy.tracing_basics.ResultStep(note: str)[source]

Bases: BaseStep

Class for result steps.

Tracing laziness

Definitions to support evaluation tracing of laziness functionality.

Copyright (c) 2024 - Eindhoven University of Technology, The Netherlands

This software is made available under the terms of the MIT License.

class FuPy.tracing_laziness.EvaluationStep(note: str)[source]

Bases: BaseStep

Class for evaluation steps.

class FuPy.tracing_laziness.GettingStep(note: str)[source]

Bases: BaseStep

Class for getting steps (from cache).

class FuPy.tracing_laziness.SuspensionStep(note: str)[source]

Bases: BaseStep

Class for Lazy creation steps.