libraryextensions/hello/lib/Hello.xtl

Hello.xtl -- the facade of the hello extension, the smallest X_eTaL native extension: each function proves one thing about the boundary. Import: "hx:" u_se< "Hello" Run with xetal-x (xetal-x --ext DIR puts this directory on XETAL_PATH). Each line below is a native function's signature; the binding macro (lib/Ffi.xtlm, docs/ffi-macro.md) writes the facade function from it.

source · imports ffi: lib/Ffi.xtlm

ˡa̲nswer : Unit -> Int

function · line 11

The answer, 42.

"a_nswer : unit -> int"        ᶠᶠⁱb̲ind< "hello/answer"
ᶠᶠⁱb̲ind< expands to
ˡa̲nswer ← { @ →
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:hello/answer"
}

ˡa̲dd : (Num a, Num b) => a -> b -> Float

function · line 13

Left plus right, added natively.

"a_dd : float float -> float"  ᶠᶠⁱb̲ind< "hello/add"
ᶠᶠⁱb̲ind< expands to
ˡa̲dd ← { a b →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:hello/add?float=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:hello/add?float=" c̲at f̲ormat s̲hape b
  f̲irst n̲umbers ⎕N̲GET "ext:hello/add"
}

ˡs̲hout : Char -> Char

function · line 15

The text in upper case (Unicode).

"s_hout : text -> text"        ᶠᶠⁱb̲ind< "hello/shout"
ᶠᶠⁱb̲ind< expands to
ˡs̲hout ← { a →
  pa ← a ⎕N̲PUT "ext:hello/shout?text"
  ⎕N̲GET "ext:hello/shout"
}

ˡs̲um : Num a => a -> Float

function · line 17

The sum of every element of a numeric array.

"s_um : float -> float"        ᶠᶠⁱb̲ind< "hello/sum"
ᶠᶠⁱb̲ind< expands to
ˡs̲um ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:hello/sum?float=" c̲at f̲ormat s̲hape a
  f̲irst n̲umbers ⎕N̲GET "ext:hello/sum"
}

ˡe̲cho : Num a => a -> Float

function · line 19

A numeric array sent across and back: the same values and shape.

"e_cho : float -> floats"      ᶠᶠⁱb̲ind< "hello/echo"
ᶠᶠⁱb̲ind< expands to
ˡe̲cho ← { a →
  pa ← (f̲ormat r̲avel f̲loat a) ⎕N̲PUT "ext:hello/echo?float=" c̲at f̲ormat s̲hape a
  v ← n̲umbers ⎕N̲GET "ext:hello/echo"
  (f̲loor n̲umbers ⎕N̲GET "ext:hello/echo?shape") r̲eshape v
}

ˡf̲ail : Unit -> Int

function · line 21

Always fails: a native error is an X_eTaL error.

"f_ail : unit -> int"          ᶠᶠⁱb̲ind< "hello/fail"
ᶠᶠⁱb̲ind< expands to
ˡf̲ail ← { @ →
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:hello/fail"
}

ˡp̲anic : Unit -> Int

function · line 23

Always panics inside Rust: contained, reported as an X_eTaL error.

"p_anic : unit -> int"         ᶠᶠⁱb̲ind< "hello/panic"
ᶠᶠⁱb̲ind< expands to
ˡp̲anic ← { @ →
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:hello/panic"
}

ˡpackage : Char

value · line 27

The native package behind these functions (a literal l: name also makes this file a library to xetal type: ask E7).

ˡpackage ← "hello"