curry.icurry.json module

class curry.icurry.json.Encoder(compact=True, **kwds)[source]

Bases: JSONEncoder

Encodes ICurry as JSON.

The compact form, the default, has no space after a comma or a colon. Both forms escape every character outside ASCII. The toolchain writes the compact form into the .json.z caches.

KEY_MAP = {'IDataType': 'IType', 'IModule': 'IProg', 'filename': None, 'fullname': 'name', 'symbolname': 'name'}
VALUE_MAP = {'aliases': <function Encoder.<lambda>>, 'functions': <function Encoder.<lambda>>, 'imports': <function Encoder.<lambda>>, 'types': <function Encoder.<lambda>>}
default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
curry.icurry.json.dump(icurry, file, compact=True)[source]
curry.icurry.json.dumps(icurry, compact=True)[source]

Dump ICurry as JSON. See Encoder for the two forms.

curry.icurry.json.get_decoder()[source]
curry.icurry.json.get_encoder(compact=True)[source]
curry.icurry.json.load(file, decoder=get_decoder())[source]
curry.icurry.json.loads(json, decoder=get_decoder())[source]

Load ICurry encoded as JSON.