phst_transform v1.0.2 PhStTransform.Potion

This module provides some helper methods for creating maps that work with the PhStTransform Protocol.

The methods in this module that are public are not intended to be used outside of writing a implementation of the PhStTransform Protocol or a PhStTransform map function.

Summary

Functions

brew validates and prepares a map to be used with the PhStTransform Protocol

brewify converts a potion from transmogrify form into one compatible with transform

concoct is the version of brew used in transmogrify, it expects functions of either arity 2 or 3 and use a similar wrap function. It also checks for whether any functions need wrapping at every level

distill extracts the function for a given data type from a potion

Functions

brew(map, depth)

brew validates and prepares a map to be used with the PhStTransform Protocol.

Every key in the map that is an Atom and that starts with Elixir. must have a function as a value. That function must have either arity 1 or 2 and if it is arity 1, it must be wrapped with arity 2 closure.

This validation only occurs at the top of the transformation tree when the depth list is empty.

brewify(map)

brewify converts a potion from transmogrify form into one compatible with transform.

The idea is to use transmogrify to build a potion that can be used in transforms.

concoct(map, depth)

concoct is the version of brew used in transmogrify, it expects functions of either arity 2 or 3 and use a similar wrap function. It also checks for whether any functions need wrapping at every level.

distill(type, potion)

distill extracts the function for a given data type from a potion.

If the potion does not have a function for a given data type, it returns the function from the Any key value.