I recently cloned Tom Schrijvers’ type_check
library to understand it better and hopefully make a small number of improvements/documentation and make it available again as a pack.
When importing that library, a singleton variable warning is generated for lines like:
:- type list(T) ---> [] ; [T|list(T)].
(that’s defined in the library itself, see here).
Oddly, this other version, that doesn’t have branches, would work without warnings:
:- type list(T) ---> [T|list(T)].
So I guess the error is saying that if we assigned a procedural meaning to that code and choose the []
branch, I would have list[T] ---> []
and that T is a singleton variable. This is a substantial problem because it will generate a warning also for each user-defined polymorphic type that doesn’t have all the type variables in each constructor.
My question for you is: what could I do to convince swipl
that that warning is undeserved? I know that I could disable singletons checking via :- style_check(-singleton).
but that seems a very heavy hammer: I actually want singleton checking, it’s just that it shouldn’t happen here.