COMMUNITY

FP / Persistent Data Structures

I’ve been trying to use more functional/immutable approach in Haxe and while the support for FP in general is good, I haven’t been able to find any kind of support for Persistent Data Structures.
I’ve been using structural typing and reflection as an alternative to persistent records/maps in simpler cases, but I’m looking for more efficient alternative.

The closest thing I found is tink_pure, but that doesn’t seem to be ready to be used in real projects.

(the link on https://lib.haxe.org/p/tink_pure/ is 404, so here’s the direct link to the repo: https://github.com/haxetink/tink_pure)

tink_pure is used in real projects!

The implementations for List, Array, Map (that is tink.pure.List, Slice, Mapping) are rather minimalistic at the moment (it does the job though) and IIRC some of them may be rewritten while retaining the same interface.

If you’re into FP, immutable stuffs and the likes, the tink libs could be interesting for you. I would first start looking at tink_core, even if though if you just have specific needs tink_pure and tink_anon may be enough for you (the latter to just create a modified copy of an immutable anonymous object with tink.Anon.merge).

If you have question about some tink libs then, there is this chatroom: https://gitter.im/haxetink/public

+Docs : https://haxetink.github.io

1 Like

Thank you for the info.
Regarding tink_pure, @back2dos said that the current implementation is naive and slow and needs to be replaced with something more serious. Are there any plans for that in the near future?

There are no concrete plans, because that’s a sizable undertaking, that needs to be tackled per platform. As said, the status quo is good enough for the people using it, but if you require the performance characteristics of clojure, then you’re not going to get it from tink_pure.

What I would suggest is to use abstracts to create a consistent API over whatever native libs service your needs.

No, I don’t need that. Something in the range of immutable.js (or a bit slower) would be fine. Obviously, advantage of tink_pure is that it’s cross platform.