curry.show module
- class curry.show.DefaultStringifier(**kwds)[source]
Bases:
FreeVarStringifier,ListStringifier,LitNormalStringifierA stringifier for REPL output. This translates free variables into identifiers _a, _b, etc. and represents literals in the usual, human-readable, way.
- class curry.show.FreeVarStringifier(**kwds)[source]
Bases:
StringifierRepresents free variables as _a, _b, etc.
- class curry.show.ListStringifier(style='str')[source]
Bases:
StringifierFormats lists using the best style. Depending on the list type and whether it is ground, the style will use square brackets, cons symbols, or double-quotes.
- format_as_list(arg, **kwds)[source]
Formats lists using square-bracket-style, when possible; or, if some tail is a non-constructor symbol, then using cons symbols.
- format_as_string(tail, **kwds)[source]
A list of Chars is formatted as a double-quoted string. The list must be non-nil, each element must be a ground value of type Prelude.Char or unboxed character data, and the list itself must consist of only ground values. If these conditions are not met None is returned.
- class curry.show.LitNormalStringifier(style='str')[source]
Bases:
StringifierRepresents literals in the usual, human-readable, way.
- class curry.show.LitUnboxedStringifier(style='str')[source]
Bases:
StringifierRepresents unboxed literals by appending a #.
- class curry.show.PlainFreeVarsStringifier(style='str')[source]
Bases:
ListStringifier,LitNormalStringifier
- class curry.show.Stringifier(style='str')[source]
Bases:
objectRecursively invokes
showon the argument.Two styles are supported. In ‘str’ mode, the implementation tries to match the output to natural Curry syntax. Lists, for instance, are written using brackets and parentheses are added where needed. In ‘repr’ mode, the output more closely reflects the node structure of the graph. Each node is written in label-successor form within angle brackets.
In both modes, cyclical expressions are displayed by replacing back-references with ellipses.
- Parameters:
style – One of ‘str’ or ‘repr’.
- Returns:
A string.
- stringify(arg, outer=False, partial=False)[source]
Converts the argument to a string according to the specified style. Subclasses are expected to override the
formatmethod to apply special formatting.Unless
outeris True, the result will be parenthesized if it contains spaces and does not begin with a bracket-like character.If
partialis supplied, the argument treated as a subexpression of a partial application.
- curry.show.escape_char(char, quote)[source]
Writes one character as it appears in a literal delimited by
quote. Printable ASCII is written as is. Every other code point is written as a decimal escape of at least two digits, as PAKCS writes it: show ‘228’ is “’\228’”.
- curry.show.show(arg, stringifier=None, **kwds)[source]
Converts an expression to a string.
- Parameters:
stringifier – Specifies a callable object used to stringify subexpressions. This can be used to apply arbitrary translations, e.g., from free variables to stylized names such as _a, _b, etc.
kwds – As an alternative to supplying the stringifier, when
stringifieris None, additional keywords are passed to the constructor of the default stringifier.
- Returns:
The string representation of
arg.
- curry.show.show_float(value)[source]
The text of a Float as PAKCS writes it, so that both backends print one text (issue #34).
The digits are the shortest that read back to the same value, the digits of
repr. The point stands in the digits when the value is at least 1.0e-4 and either below 1.0e15 or not integral; otherwise the text is d.ddde<exp>, where the exponent carries its sign and no padding, and a lone digit gets “.0”: 0.0001, 1.0e-5, 10000000.0, 1.0e+15, 1.0e+22. An integral value ends in “.0”. The infinities and NaN, which PAKCS cannot make, are written Infinity, -Infinity, and NaN, as KiCS2 writes them. The C++ runtime has the same rule in graph/show.cpp.