index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <!doctype html>
  2. <html lang="en-nz">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Invercargill — Astrologue Developer</title>
  7. <meta name="description" content="Invercargill is the Enumerable library for Vala — LINQ-style querying plus the Vector, Dictionary, Series and buffer data structures the whole Astrologue stack is written against. Free software, LGPL-3.0-or-later.">
  8. <meta name="color-scheme" content="light dark">
  9. <meta name="theme-color" content="#f2ebda" media="(prefers-color-scheme: light)">
  10. <meta name="theme-color" content="#0a0a12" media="(prefers-color-scheme: dark)">
  11. <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Ccircle cx='32' cy='32' r='27' fill='none' stroke='%23a8801f' stroke-width='4'/%3E%3Cpath d='M32 8l6 18 18 6-18 6-6 18-6-18-18-6 18-6z' fill='%23a8801f'/%3E%3Ccircle cx='32' cy='32' r='4' fill='%23003078'/%3E%3C/svg%3E">
  12. <meta property="og:title" content="Invercargill — Astrologue Developer">
  13. <meta property="og:description" content="The Enumerable library for Vala: LINQ-style querying plus Vector, Dictionary, Series, buffers, sets and heaps — the foundation the Astrologue stack is written against.">
  14. <meta property="og:type" content="website">
  15. <link rel="stylesheet" href="../../assets/css/style.css">
  16. </head>
  17. <body>
  18. <a class="skip-link" href="#main">Skip to content</a>
  19. <header class="masthead">
  20. <div class="container masthead__inner">
  21. <a class="brand" href="../../">
  22. <img class="brand__logo brand__logo--light" src="../../assets/img/astrologue-light.png" width="392" height="89" alt="Astrologue">
  23. <img class="brand__logo brand__logo--dark" src="../../assets/img/astrologue-dark.png" width="392" height="89" alt="Astrologue">
  24. </a>
  25. <nav class="site-nav" aria-label="Primary">
  26. <ul class="site-nav__list">
  27. <li><a href="../../">Home</a></li>
  28. <li><a href="../../#news">News</a></li>
  29. <li><a href="../../#download">Download</a></li>
  30. <li><a href="../" aria-current="page">Developer</a></li>
  31. <li><a class="nav-cta" href="../../#download">Get Astrologue</a></li>
  32. </ul>
  33. </nav>
  34. </div>
  35. </header>
  36. <main id="main">
  37. <nav class="breadcrumb" aria-label="Breadcrumb">
  38. <div class="container">
  39. <ol>
  40. <li><a href="../../">Astrologue</a></li>
  41. <li><a href="../">Developer</a></li>
  42. <li aria-current="page">Invercargill</li>
  43. </ol>
  44. </div>
  45. </nav>
  46. <section class="docs-header">
  47. <div class="container">
  48. <p class="kicker"><span>Foundation · The collections beneath everything</span></p>
  49. <h1>Invercargill</h1>
  50. <p class="lede">The Enumerable library for Vala — LINQ-style querying plus the data structures the whole Astrologue stack is written against. Every row a database returns, every setting a server reads, every key a cryptographer signs passes through this library.</p>
  51. <dl class="docs-facts">
  52. <div><dt>Version</dt> <dd><code>1.0.0</code></dd></div>
  53. <div><dt>Licence</dt> <dd>LGPL-3.0-or-later</dd></div>
  54. <div><dt>Package</dt> <dd><code>usm&nbsp;install&nbsp;invercargill</code></dd></div>
  55. <div><dt>Language</dt> <dd>Vala</dd></div>
  56. </dl>
  57. </div>
  58. </section>
  59. <section class="band band--plain" id="docs">
  60. <div class="container docs-layout">
  61. <nav class="docs-toc" aria-label="On this page">
  62. <h2>On this page</h2>
  63. <ul>
  64. <li><a href="#overview">Overview</a></li>
  65. <li><a href="#features">Features</a></li>
  66. <li><a href="#installation">Installation</a></li>
  67. <li><a href="#usage">Usage &amp; documentation</a></li>
  68. <li><a href="#package">Package &amp; source</a></li>
  69. </ul>
  70. </nav>
  71. <div class="docs-prose">
  72. <header class="section-head" id="overview">
  73. <p class="kicker"><span>Overview</span></p>
  74. <h2>Why it exists</h2>
  75. </header>
  76. <p>Invercargill is a comprehensive data-manipulation library for the Vala programming language. Its central <code>Enumerable&lt;T&gt;</code> type makes working with data sets significantly more intuitive and less cognitively taxing, with a rich set of functional-programming tools for transformation, querying and manipulation.</p>
  77. <p>It exists because its author — a C# developer by trade — kept missing the operations the .NET <code>IEnumerable</code> interface provides. Unwilling to settle for LibGee, he rolled a library of his own and named it after New Zealand's southernmost city. It takes heavy inspiration from C#'s interface, adapted where Vala's nuances call for it, and adds unique functions and structures of its own.</p>
  78. <p>Today it is the foundation of the Astrologue stack: the query results of <a href="../invercargill-sql/">Invercargill-Sql</a> arrive as lazy <code>Enumerable</code> rows, <a href="../inversion/">Inversion</a> resolves its registrations through it, and every library above leans on its data structures instead of <code>GLib.ArrayList</code> or LibGee.</p>
  79. <header class="section-head" id="features">
  80. <p class="kicker"><span>Features</span></p>
  81. <h2>What it hands you</h2>
  82. </header>
  83. <ul class="docs-features">
  84. <li><strong>Enumerable everywhere.</strong> One interface for iteration, transformation, filtering, aggregation, set operations, ordering, partitioning and grouping — chained fluently.</li>
  85. <li><strong>Data structures.</strong> Vector, Series, SortedSeries, Dictionary, HashSet, Buffer, ByteBuffer, RingBuffer, PriorityQueue, Fifo and Lifo, each with a job.</li>
  86. <li><strong>Lazy evaluation.</strong> Sequences are computed as they are walked, with caching mechanisms for when a second pass should not recompute.</li>
  87. <li><strong>Parallel processing.</strong> Built-in parallel operations to leverage multi-core processors.</li>
  88. <li><strong>Numbers as sequences.</strong> Promotions turn an <code>Enumerable&lt;int&gt;</code> into a numeric view with <code>sum()</code>, <code>average()</code> and friends.</li>
  89. <li><strong>Attempts.</strong> Safe operation handling with error recovery, so a fallible step can be retried or abandoned without ceremony.</li>
  90. </ul>
  91. <header class="section-head" id="installation">
  92. <p class="kicker"><span>Installation</span></p>
  93. <h2>Getting the library</h2>
  94. </header>
  95. <p>With USM on your machine, one command acquires, builds and installs the library together with its C header, Vala binding and introspection:</p>
  96. <figure class="code-plate">
  97. <pre><code>usm install invercargill</code></pre>
  98. <figcaption>Installs from the Astrologue package repository.</figcaption>
  99. </figure>
  100. <p>From source, the library follows the stack's one-build discipline:</p>
  101. <figure class="code-plate">
  102. <pre><code>git clone &lt;the Invercargill repository&gt;
  103. cd Invercargill
  104. meson setup src build
  105. ninja -C build
  106. ninja -C build install</code></pre>
  107. <figcaption>The build lives in <code>src/</code>; the README and the package scripts agree on it.</figcaption>
  108. </figure>
  109. <p>Then compile against it with Vala's usual package mechanism:</p>
  110. <figure class="code-plate">
  111. <pre><code>valac --pkg invercargill-1 my-program.vala</code></pre>
  112. <figcaption>The <code>-1</code> suffix keeps the ABI generation honest.</figcaption>
  113. </figure>
  114. <header class="section-head" id="usage">
  115. <p class="kicker"><span>Usage &amp; documentation</span></p>
  116. <h2>Working with sequences</h2>
  117. </header>
  118. <p>Wrap anything enumerable — an array, a generic array, a stream — and work with it through the fluent API. These idioms are lifted from the library's own integration tests:</p>
  119. <figure class="code-plate">
  120. <pre><code>using Invercargill;
  121. var items = Wrap.array(new int[] { 1, 2, 3, 4, 5 });
  122. var result = items.aggregate&lt;int&gt;(0, (sum, item) =&gt; sum + item);
  123. // result == 15
  124. var words = Wrap.array(new string[] { "Hello", " ", "World", "!" });
  125. var greeting = words.aggregate&lt;string&gt;("", (concat, item) =&gt; concat + item);
  126. // greeting == "Hello World!"</code></pre>
  127. <figcaption>From <code>src/tests/Integration/EnumerableMethods.vala</code> — <code>aggregate</code> folds a sequence down to one value.</figcaption>
  128. </figure>
  129. <p>Predicates come in matched pairs, and empty sequences answer honestly:</p>
  130. <figure class="code-plate">
  131. <pre><code>var evens = Wrap.array(new int[] { 2, 4, 6, 8 });
  132. evens.all(i =&gt; i % 2 == 0); // true
  133. evens.any(i =&gt; i == 5); // false
  134. evens.no(i =&gt; i % 2 == 1); // true — nothing matches
  135. var empty = Wrap.array(new int[] {});
  136. empty.any(); // false
  137. empty.no(); // true</code></pre>
  138. <figcaption><code>all</code>, <code>any</code> and <code>no</code> — the last is the existential negative LibGee never gave Vala.</figcaption>
  139. </figure>
  140. <p>Ordering and projection compose like their C# cousins:</p>
  141. <figure class="code-plate">
  142. <pre><code>var items = ClassToOrder.data();
  143. var result = items.order_by&lt;int&gt;(i =&gt; i.id);
  144. var ids = result.select&lt;int&gt;(i =&gt; i.id);
  145. var newest_first = items.order_by_descending&lt;string&gt;(i =&gt; i.name);</code></pre>
  146. <figcaption>From <code>src/tests/Integration/OrderBy.vala</code>.</figcaption>
  147. </figure>
  148. <p>The modifier vocabulary goes much further — <code>where()</code>, <code>from()</code>, <code>until()</code> for filtering; <code>select()</code>, <code>select_many()</code>, <code>cast()</code>, <code>of_type()</code> for transformation; <code>combine()</code>, <code>common()</code>, <code>exclude()</code>, <code>distinct()</code> for set operations; <code>take()</code>, <code>skip()</code>, <code>chunk()</code>, <code>window()</code> for partitioning; and <code>zip()</code>, <code>concat()</code>, <code>interleave()</code>, <code>cycle()</code> for combination.</p>
  149. <h3>The data structures</h3>
  150. <p>Alongside the query layer sit the collections the stack is actually written with — used in place of <code>GLib.ArrayList</code>, <code>GLib.List</code> and <code>GLib.HashTable</code>:</p>
  151. <figure class="code-plate">
  152. <pre><code>using Invercargill.DataStructures;
  153. var data = new Vector&lt;int&gt;();
  154. data.add(5);
  155. data.add(15);
  156. data.add(10);
  157. var numbers = data.assert_promotion&lt;SignedNativeIntegers&gt;();
  158. var mean = numbers.average(); // 10
  159. var dict = new Dictionary&lt;int, string&gt;();
  160. dict[1999] = "Billy";
  161. dict[1962] = "John";
  162. string? billy = dict.get_or_default(1999);</code></pre>
  163. <figcaption>From <code>src/tests/Integration/Numbers.vala</code> and <code>Dictionary.vala</code>. A promotion turns a plain sequence into a numeric view.</figcaption>
  164. </figure>
  165. <p>The full set: <strong>Vector</strong> (dynamic array), <strong>Series</strong> (linked list, efficient at both ends), <strong>SortedSeries</strong> (red-black tree, kept in order), <strong>Dictionary</strong> (key-value store), <strong>HashSet</strong> (hash table with tombstone deletion), <strong>Buffer</strong> and <strong>ByteBuffer</strong>, <strong>ImmutableBuffer</strong>, <strong>RingBuffer</strong> (circular, iterable forever), <strong>PriorityQueue</strong> (min-heap, thread-safe push/pop), and <strong>Fifo</strong>/<strong>Lifo</strong> (thread-safe queue and stack with blocking operations and unblocking support).</p>
  166. <p>The library also carries an expressions subsystem, property mapping, debugging utilities and the promotion system shown above. Its test suite — integration and speed — runs through <code>meson test</code> and through USM's <code>test</code> exec, so what is documented here is what is exercised.</p>
  167. <header class="section-head" id="package">
  168. <p class="kicker"><span>Package &amp; source</span></p>
  169. <h2>The ledger</h2>
  170. </header>
  171. <dl class="docs-package">
  172. <div><dt>Version</dt><dd><code>1.0.0</code> (from <code>MANIFEST.usm</code>)</dd></div>
  173. <div><dt>Licence</dt><dd>LGPL-3.0-or-later — free to run, study, share and improve; the LGPL keeps it free to link from any program.</dd></div>
  174. <div><dt>Package</dt><dd><code>usm install invercargill</code></dd></div>
  175. <div><dt>Provides</dt><dd><code>libinvercargill-1.so</code>, <code>invercargill-1.h</code>, <code>invercargill-1.vapi</code> + <code>.deps</code>, <code>invercargill-1.gir</code>, <code>invercargill-1.typelib</code>, <code>invercargill-1.pc</code></dd></div>
  176. <div><dt>Needs at runtime</dt><dd>GLib and GObject — nothing else. The foundation carries no dependencies of its own.</dd></div>
  177. <div><dt>Source</dt><dd>The repository <code>Tilo15/Invercargill</code> on the Astrologue forge (git over ssh, port 222). Free software: the licence guarantees your right to the source.</dd></div>
  178. </dl>
  179. <nav class="docs-siblings" aria-label="Built on Invercargill">
  180. <p>The libraries that stand on it directly:</p>
  181. <ul>
  182. <li><a href="../invercargill-json/">Invercargill-Json</a></li>
  183. <li><a href="../invercargill-sql/">Invercargill-Sql</a></li>
  184. <li><a href="../inversion/">Inversion</a></li>
  185. </ul>
  186. </nav>
  187. <nav class="docs-pager" aria-label="Project pages">
  188. <p class="docs-pager__up"><a href="../">All eleven</a></p>
  189. <a class="docs-pager__link docs-pager__link--next" href="../invercargill-json/">
  190. <span>Next in the catalogue</span>
  191. <strong>Invercargill-Json</strong>
  192. </a>
  193. </nav>
  194. </div>
  195. </div>
  196. </section>
  197. </main>
  198. <footer class="site-footer">
  199. <div class="container">
  200. <div class="footer-grid">
  201. <div class="foot-brand">
  202. <img class="brand__logo brand__logo--dark" src="../../assets/img/astrologue-dark.png" width="392" height="89" alt="Astrologue">
  203. <p>An operating system for change — kept for self sufficiency, resilience, and software freedom, so regular people can hold the power of general purpose computers in their own hands.</p>
  204. </div>
  205. <nav aria-label="The four freedoms">
  206. <p class="foot-title">The Four Freedoms</p>
  207. <ol class="freedoms">
  208. <li><strong>Run</strong> the software as you wish, for any purpose.</li>
  209. <li><strong>Study</strong> the source and change it to do your computing as you wish.</li>
  210. <li><strong>Share</strong> copies so you can help others.</li>
  211. <li><strong>Modify</strong> and publish your versions so everyone benefits.</li>
  212. </ol>
  213. </nav>
  214. <nav aria-label="Site">
  215. <p class="foot-title">Site</p>
  216. <ul class="foot-list">
  217. <li><a href="../../">Home</a></li>
  218. <li><a href="../../#news">News</a></li>
  219. <li><a href="../../#download">Download</a></li>
  220. <li><a href="../">Developer</a></li>
  221. </ul>
  222. </nav>
  223. </div>
  224. <p class="colophon">Set in Cinzel and EB Garamond (SIL Open Font License). Astrologue is free software, licensed GPL-3.0-or-later: take it, tend it, pass it on. The libraries are LGPL-3.0-or-later, so they remain free to link.</p>
  225. </div>
  226. </footer>
  227. </body>
  228. </html>