:- module salut_example.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module salut, list.

:- type world ---> world.
:- type animal
    --->    dog(string)
    ;       cat(string).

:- instance greetable(world) where [
    the(world) = "The",
    name(world) = "World"
].

:- instance greetable(animal) where [
    the(dog(_)) = "The dog",
    the(cat(_)) = "The Right Honorable Purr",

    name(dog(X)) = X,
    name(cat(X)) = X
].

main(!IO) :-
    hello(arriving(world), !IO),
    announce([
        arriving(dog("Spot")),
        nothing(1),
        arriving(cat("Ruffles")),
        nothing(1),
        leaving(cat("Ruffles"))
    ], !IO),
    hello(leaving(world), !IO).