PropWise.PurityAnalyzer
(PropWise v0.3.2)
View Source
Analyzes function ASTs to determine if they are pure (no side effects).
Configuration
Side effect detection can be customized by providing options:
analyze(function_info, side_effect_calls: [...], side_effect_functions: [...])Side Effect Calls
List of {module, function, arity} tuples that indicate side effects.
Supports wildcards:
{Module, :*, :*}- All functions in module{Module, :function, :*}- All arities of function
Side Effect Functions
List of {function, arity} tuples for bare function calls that indicate side effects.
Summary
Functions
Analyzes a function to determine if it's pure.
Returns {:pure, []} or {:impure, side_effects}.
Returns true if the function appears pure.
Functions
@spec analyze( PropWise.FunctionInfo.t() | map(), keyword() ) :: {:pure, []} | {:impure, [tuple()]}
Analyzes a function to determine if it's pure.
Returns {:pure, []} or {:impure, side_effects}.
Options
:side_effect_calls- List of{module, function, arity}tuples (default: built-in list):side_effect_functions- List of{function, arity}tuples (default: built-in list)
Examples
analyze(function_info)
analyze(function_info, side_effect_calls: [{MyModule, :impure_func, 1}])
@spec pure?( PropWise.FunctionInfo.t() | map(), keyword() ) :: boolean()
Returns true if the function appears pure.
Accepts the same options as analyze/2.