Experimental library for type-class-like polymorphic predicates

Hello, this is my first post here and I wanted to share a small project I’ve been tinkering with for some time and now thanks to the quarantine had some more time to work on.

I work with functional Scala at my job and I was curious to see how some basic type classes would translate to Prolog. What i came up with is that my predicates can take an additional term that describes the structure of values i pass to them, effectively exchanging composition of predicates to composition of type declarations when complex data is processed, like this:

% list of lists of integers with addition
?- reduce(list / list(int(+)), [[1,2],[3]], Result).
Result = 6

Some more examples are available in the repo:

I’m not sure how useful this sort of approach can be but I think I am going to develop it further and try to use it in something small. Any feedback or comments appreciated.


FYI in case you were not aware. Not implying anything by noting.

Package type_check
Package typedef