Thanks for the working example!
I see you added the compiler directive {$mode Delphi}{$H+}
Using generics is a bit confusing to me. There seem to be 2 (or 3!) ways!
Generics.Collections, FGL, and lgenerics
And two compiler directivs {$mode objfpc}{$H+} and {$mode Delphi}{$H+}.
Again, Thank you for your help.
Here's the gist of it.
For the modes, objfpc indicates the Free Pascal dialect of the Object Pascal language, and you can probably guess what delphi does.

It is a matter of personal preference, although objfpc, being the main dialect, will receive new features faster.
Generics.Collections is the newest of all of these. It comes from rtl-generics, which is a larger, somewhat more featureful collection of generic containers written in
{$mode delphi}, intended to be compatible with the Delphi counterpart. It is included since FPC 3.1.1+, but there's a version for 3.0.4 too. Since it is pretty much one to one (or at least as close as it can be), you can just use the Delphi docs. I personally consider the API of Generics.Collections to be cleaner and has more features, so it's the one I default to.
FGL, or Free Generics Library, is a FPC-native collection of generic containers written in
{$mode objfpc}. IMO, it's slightly more cumbersome to use, but it was there first, so there's that. It gets the job done, so you can still see it in some code around.
As for lgenerics, it is an external package made by A. Koverdyaev (avk) and requires FPC 3.2.2+ and Lazarus 2.2+. It is the king when it comes to anything tree/graph-related. It has the most features, some not related to data structures at all, such as 128 bit integers, non-cryptographic hashes, channels and thread pools, as well as full support for JSON (including serializing JSON from native data structures using RTTI) and CSV. It seems to be pretty performant too, so it isn't a bad choice.
If you have FPC 3.2.2 and you only need things like dictionaries, stacks, queues, thread lists or lists, then Generics.Collections is the way to go. Otherwise, if you're fine with external dependencies, lgenerics is a good choice. Otherwise, have fun with FGL.