prolog
prolog copied to clipboard
Fixing bug where a term was tested for type using unification
Hi Chris, can you explain a bit why you wanted to make this change? Unless there is corresponding bug somewhere else, this bit looks right as it is, because it's comparing the value to be type checked against a nullary constructor. For example, a maybe
type like in Haskell would be declared as :- type maybe(A) ---> nothing; just(A)
. The presence of the nullary constructor nothing
means that the term nothing
has type maybe(A)
for any type A
. In such a case, user_type_constructor(maybe(A), Cons)
will succeed with Const=nothing
, and hence a term Term
being type checked will have type maybe(A)
if Term
unifies with nothing
, not when error:has_type(nothing, nothing)
, which should never succeed, since nothing
is not a type.