No matching definitions.

tur/typeclass-show

stdlib/typeclass-show.tur

the Show typeclass (owned String result) and its primitive + typed-collection instances.

Show renders a value as an OWNED String (refcount 1): (show x) returns a fresh String the caller string/releases, so a generic caller has a single uniformly-safe ownership policy (release) -- no leak, no borrow/malloc guessing. This is the owned surface the show-owned-result-plan builds; the earlier cstr-returning Show was retired at stage 4.

Because it returns String, Show sits ABOVE stdlib/string.tur in the load graph and loads it here. It is pulled in by stdlib/typeclass.tur (so (load "stdlib/typeclass.tur") still provides Show + the collection instances) and preloaded by the REPL (src/turi/preload.c).

Since: v2 (show-owned-result-plan, stage 4)

defclass

Show

(defclass Show [a])

values that render themselves as an owned String.

athe type to render
(show [x] :String)

a fresh owned String (refcount 1) rendering x -- [1 2 3] for a Vec, #\A for a Char. The caller string/releases it.

(let [s (show 42)] (println (string/to-cstr s)) (string/release s))   ; prints 42

For human-facing text without the ownership step, see Display (cstr) in stdlib/typeclass.tur.

Since: Phase 15 (owned since stage 4)

definstance

Show[int]

(definstance Show [int])

owned decimal String.

definstance

Show[cstr]

(definstance Show [cstr])

copy the borrowed cstr into a fresh owned String.

definstance

Show[bool]

(definstance Show [bool])

owned "true" / "false" String.

definstance

Show[int8]

(definstance Show [int8])

owned decimal String.

definstance

Show[int16]

(definstance Show [int16])

owned decimal String.

definstance

Show[int32]

(definstance Show [int32])

owned decimal String.

definstance

Show[uint8]

(definstance Show [uint8])

owned decimal String.

definstance

Show[uint16]

(definstance Show [uint16])

owned decimal String.

definstance

Show[uint32]

(definstance Show [uint32])

owned decimal String.

definstance

Show[uint64]

(definstance Show [uint64])

owned decimal String.

definstance

Show[float]

(definstance Show [float])

owned String rendering of a double.

definstance

Show[float32]

(definstance Show [float32])

owned String rendering of a float32.

definstance

Show[String]

(definstance Show [String])

O(1) retain (refcount++), a second owning handle.

definstance

Show[ptr<void>]

(definstance Show [ptr<void>])

render a result<T,E> carrier as an owned String.

defn

vec-show-loop

(vec-show-loop [^Show A])

push "e0 e1 ..." element reprs into the builder.

definstance

Show[Vec]

(definstance Show [Vec])

render a Vec[A] as an owned "[a b c]" String.

(show (vec-of 1 2 3))  ; => String "[1 2 3]"
defn

set-show-loop

(set-show-loop [^Show A])

push the space-separated element reprs into b.

definstance

Show[Set]

(definstance Show [Set])

render a Set[A] as an owned "#set{a b c}" String.

(show (set-of 1 2 3))  ; => String "#set{1 2 3}"
defn

map-show-loop

(map-show-loop [^Show K ^Show V])

push the space-separated "k v" reprs into b.

definstance

Show[Map]

(definstance Show [Map])

render a Map[K V] as an owned "#map{k1 v1 k2 v2}" String.

(show (hamt-of 1 10 2 20))  ; => String "#map{1 10 2 20}"
defn

show-char-name__

(show-char-name__ [n :int] :cstr)

internal: the reader's name for code n ("" if none).

defn

show-char-named?__

(show-char-named?__ [n :int] :bool)

internal: does the reader have a name for code n?

defn

show-hex-digit__

(show-hex-digit__ [d :int] :Char)

internal: the lower-case hex digit for 0..15.

definstance

Show[Char]

(definstance Show [Char])

render a character as its literal: #\A, #\space.

(show #\A)      ; => String "#\A"
(show #\space)  ; => String "#\space"
definstance

Show[Sym]

(definstance Show [Sym])

render an interned symbol as an owned ":name" String.

(show :hello)  ; => String ":hello"
defn

show-string-fputs

(show-string-fputs [s :cstr])

internal: write a cstr to stdout with no newline.

defn

show-line

(show-line [^Show a])

render x via Show and print it with a trailing newline.

Shows x to an owned String, prints its bytes plus a newline, releases it.

(show-line 42)  ; prints: 42\n

Since: v2 (show-owned-result-plan)