On this page
Verada.Vibe
Compatibility helpers for Vibe images.
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
Image turns an Ada image into Python's spelling; Float_Image writes a Long_Float as Python's repr does; Repr, Joined, Paired and Enclosed make Python's repr of a list, a dict, a set and a tuple.
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
with Verada.Vibe;import Verada.Vibe;
A Vibe module imports this unit's names with from Verada.Vibe import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
ArithmeticError, ZeroDivisionError, OverflowError, FloatingPointError (declaration) — Python's arithmetic exceptions, which Vibe raises and handles by name; except ArithmeticError handles the others (the front end follows Python's hierarchy).
Declared interface:
ArithmeticError, ZeroDivisionError, OverflowError, FloatingPointError : exception;API 002
LookupError, IndexError, KeyError (declaration) — Python's lookup exceptions; except LookupError handles IndexError and KeyError.
Declared interface:
LookupError, IndexError, KeyError : exception;API 003
ValueError, TypeError, AttributeError, NameError, EOFError (declaration) — Python's built-in exceptions of these names, for Vibe programs to raise and handle.
Declared interface:
ValueError, TypeError, AttributeError, NameError, EOFError : exception;API 004
RuntimeError, NotImplementedError, RecursionError, StopIteration (declaration) — Python's run-time exceptions; except RuntimeError handles NotImplementedError and RecursionError.
Declared interface:
RuntimeError, NotImplementedError, RecursionError, StopIteration : exception;API 005
UnicodeError, PermissionError, FileNotFoundError, OSError, TimeoutError (declaration) — Python's exceptions of these names; except OSError handles PermissionError, FileNotFoundError and TimeoutError, and except ValueError UnicodeError.
Declared interface:
UnicodeError, PermissionError, FileNotFoundError, OSError, TimeoutError : exception;API 006
Write (declaration) — Write a text to standard output as UTF-8, its code points as they are: Vibe's print writes each piece with it.
API 007
Message (declaration) — A text as an exception's or an assertion's message, which is a String: its code points as UTF-8, whole. Vibe's raise E(m) and assert c, m give a message that is not an ASCII literal through it. It is an expression function, whose value callers' proofs see.
API 008
Message_Text (declaration) — Python's str of an exception, its message read back as UTF-8; a byte sequence that is not UTF-8 reads as U+FFFD where it breaks. Vibe's str(e), print(e) and f-string fields of except E as e call it.
API 009
Image (declaration) — Convert supported Ada-style image text to Vibe numeric/Boolean spelling; it is not a universal repr protocol.
On normal return the declared contract establishes:
Image'Result'Length <= Integer'Max (Ada_Image'Length, 5)
and then (if Image'Result'Length > 0 then Image'Result'First >= 1 and then Image'Result'First - 1 <= Integer'Max (Ada_Image'First, 1))API 010
Float_Image (declaration) — Write a Long_Float as Python's repr does, as Vibe's print shows it.
On normal return the declared contract establishes:
Float_Image'Result'First = 1 and then Float_Image'Result'Length <= 32API 011
Repr (declaration) — Python's repr of an int: its digits, with a sign when negative; what a collection shows of an element.
API 012
Repr (declaration) — Python's repr of an int: its digits, with a sign when negative; what a collection shows of an element.
API 013
Repr (declaration) — Python's repr of an int: its digits, with a sign when negative; what a collection shows of an element.
API 014
Repr (declaration) — Python's repr of an int: its digits, with a sign when negative; what a collection shows of an element.
API 015
Joined (declaration) — The elements' reprs so far and the next, separated by , : the reducer of a collection's repr, [for X of C => Repr (X)]'Reduce (Joined, "").
API 016
Paired (declaration) — A dict's key and value by their reprs, k: v.
API 017
Enclosed (declaration) — A collection's repr from its elements' joined reprs: between its brackets, or the empty collection's repr ([], {}, set()) when there are none; Vibe's str and repr of a list, a dict, a set and a tuple are this.
API 018
Slice_Bound (declaration) — Python's bound of a slice xs[a:b] for a sequence of the given length: a negative bound counts from the end, and the result is kept within 0 .. Length, so a slice is never out of range. Vibe's slices of lists, strings and arrays take both bounds through it. It is an expression function, so callers' proofs see its value.
API 019
Slice_Bound_Down (declaration) — Python's slice bound for a negative step: counted from the end when negative, then kept within -1 .. Length - 1.
Declared interface:
function Slice_Bound_Down (Bound : Integer; Length : Natural) return Integer is
(if Bound < 0 then (if Bound + Length < 0 then -1 else Bound + Length)
elsif Bound >= Length then Length - 1
else Bound)
with Global => null,
Post => Slice_Bound_Down'Result in -1 .. Length - 1;