import re


def _pythonify_type(text):
    """
    Convert valid Copperhead type expression to valid Python expression.

    The Copperhead type language is very nearly syntactically valid
    Python.  To make parsing types relatively painless, we shamelessly
    convert type expressions into similar Python expressions, which we
    then feed into the Python parser.  Producing a syntactically valid
    Python expression involves the following conversions:

        - substitute 'lambda' for 'ForAll'
        - substitute '>>' for the '->' function operator
    """

    text = re.sub(r'ForAll(?=\s)', 'lambda', text)
    text = re.sub(r'->', '>>', text)

    return text.strip()