[m-users.] Question regarding predicates stored in existential data types.
philip at pswhite.org
Wed Feb 17 13:57:12 AEDT 2021
below is the type I have:
:- type flag(T)
flag_doc :: string,
flag_name :: string,
flag_kind :: flag_kind(T)
; some [A] map1_flag(flag(A), pred(A::in, T::out) is det)
; some [A, B] map2_flag(flag(A), flag(B), pred(A::in, B::in, T::out) is det).
When I deconstruct a value in the map2_flag case, and then try to call
it, I'm getting the error:
variable F [the variable that corresponds to the predicate part the
value] has instiatedness `ground', expecting higher-order pred inst of
Is the problem that 'ground' is not the same as pred(in, in, out) is
det? I tried making a new inst for flag that makes everything ground,
except the predicate part, for which it uses a predicate instantiation.
However, this turned into a mess of errors, so I'm not sure if I'm even
on the right track.
One thing I don't understand is why there needs to be a separate kind
of inst predicates. Why are ground and free not enough? Perhaps this
misunderstanding is the root the problem here?
More information about the users