Giraffe Library User Guide

This guide describes the SML interface to GObject-based libraries provided by Giraffe Library and explains how to create SML applications using this interface.

An understanding of SML and concepts relating to functional programming is assumed as such topics are outside the scope of this guide. Also, this guide does not generally attempt to explain the APIs provided by any GObject-based libraries but does (or will) demonstrate common patterns of use, especially for GTK.

Getting Started

To simply try out some example applications built with Giraffe Library, see the Examples Guide.

Various introductions are available for GObject-based libraries, especially GTK. For GTK 3, the reference manual provides an introduction in the section Getting Started with GTK+ and the Examples Guide provides SML versions of the C source code examples in the section Reference Manual Examples. Tutorials and examples written for other languages are a valuable source of information. These can be understood in terms of SML by referring to the section SML Interface, below, especially for languages other than C that also use GObject Introspection.

Note that the API for an introspectable GObject-based library is typically written in C. In principle, an API could be written in any language that can compile to the same ABI as C (e.g. Vala, Rust, Go) as long as a GIR file is available that describes the introspected API. However, it is unlikely that languages other than C will be used to write an introspectable API because GObject Introspection, which is used to generate GIR metadata files, supports only C source code.

The easiest way to start developing your own application is to modify an example from the Examples Guide as these provide their own build files for all supported compilers.

Library Overview

This section describes which parts of which libraries are provided by Giraffe Library.

SML Interface

The SML interface is organized as a collection of modules whose signatures provide a full specification of the interface. In most cases, this specification should be easy to follow but there are some exceptions, for example the encoding of classes in the SML type system (which has no notion of classes). These subsections describe the general representation of introspected entities in SML. The quick reference provides a lightweight description as a reminder.

Although Giraffe Library does not yet provide a documented API in SML, the representation of introspected entities described here allows existing documentation to be understood in terms of SML.

All supported compilers implement the same signatures allowing portable application code.

Programming

This section shows how to use the SML interface provided by Giraffe Library in common scenarios.

This section is still a work in progress. More topics will be added in future!

Using Compilers

Although the Definition of SML precisely defines the language, there is no standardized way to present SML source code to a compiler and there is considerable variation between compilers. This section shows how to use the supported compilers to build an application.