curry.toolchain.flat2icurry.terms module
Term classes for the FlatCurry and ICurry data, and two writers: one prints a
term as the showTerm of PAKCS does, the other as the show of Haskell
does.
A Curry data value is a constructor application (Term), a tuple, a
list, a string (str), a character (Char), an integer, or a
float. showterm() follows the Prolog show_term of the PAKCS
runtime, which wrote every committed .icy file. showhaskell() follows
the derived Show instances of Haskell, which the Curry front end uses to
write a FlatCurry file; a file read and shown again is byte-identical.
- class curry.toolchain.flat2icurry.terms.Char(value)[source]
Bases:
strA Curry character. A plain
stris a Curry string.
- class curry.toolchain.flat2icurry.terms.Term(*args)[source]
Bases:
objectA constructor application.
constructor()makes the subclasses. Each one has a fixed name and a fixed arity. The arguments are read by field name or through_args_.
- curry.toolchain.flat2icurry.terms.constructor(name, fields='', base=Term)[source]
Makes a term class.
fieldsnames the arguments, separated by spaces. A class without fields is a nullary constructor. Make one instance of it and use that instance everywhere.
- curry.toolchain.flat2icurry.terms.show_char(c)[source]
A character literal. The quote is escaped; the double quote is not.
- curry.toolchain.flat2icurry.terms.show_float(f)[source]
A float as SWI-Prolog prints it. The digits are the shortest that read back to the same value. The text has a decimal point. An exponent is used when the point falls more than three places before the digits or more than 15 places after them. A negative float is in parentheses.
- curry.toolchain.flat2icurry.terms.show_haskell_char(c)[source]
A Haskell character literal. The quote is escaped; the double quote is not.
- curry.toolchain.flat2icurry.terms.show_haskell_float(f)[source]
A float as the
showof Haskell prints aDouble. The digits are the shortest that read back to the same value. A value from 0.1 up to but not including ten million is written with a decimal point and at least one digit after it; any other value is written as one digit, a point, the other digits, and the exponent aftere. A negative float has a minus sign and no parentheses; the caller adds them where Haskell does.
- curry.toolchain.flat2icurry.terms.show_haskell_string(s)[source]
A Haskell string literal,
showListofChar: the double quote is escaped, and\&separates a decimal escape from a digit and\SOfrom anH. The empty string is"".
- curry.toolchain.flat2icurry.terms.show_lit_char(code)[source]
The text of one character inside a Haskell string or character literal,
showLitCharof GHC.Show, and the guard the text needs against the next character:'0'after a decimal escape, which must not run into a digit,'H'after\SO, else None. The writer of a string puts\&between the two. The double quote is not escaped here.
- curry.toolchain.flat2icurry.terms.show_string(s)[source]
A string. The empty string is the empty list, as in Prolog.
- curry.toolchain.flat2icurry.terms.show_term_char(code)[source]
The text of one character inside a string. A control character below 32 gets a two-digit decimal escape. A character above 126 gets a decimal escape.
- curry.toolchain.flat2icurry.terms.showhaskell(term)[source]
Prints a term as the
showof Haskell does with the derivedShowinstances: the format of the FlatCurry files of the Curry front end. A constructor with arguments is in parentheses when it is an argument; a negative number is in parentheses when it is an argument; the elements of a list and of a tuple are not. There is no newline.