[m-users.] Higher order type with existential quanitfication

Volker Wysk <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
Hi!

I have a predicate which takes an existentially quantified type as one of
its arguments. This predicate I want to pass to another predicate. I'm
puzzled about how to declare this.


:- type hetlist
    ---> some [T] hetcons(T, hetlist)   => att(T)
    ;    hetnil.

:- pred map_hetlist(
    (some [X] pred(X, Y)),
    hetlist,
    list(Y)
).

:- mode map_hetlist(
    in(pred(in, out) is det),
    in,
    out
) is det.

map_hetlist(_, hetnil, []).

map_hetlist(Pred, hetcons(X, L), [Y|Ys]) :-
    Pred(X, Y),
    map_hetlist(Pred, L, Ys).


The compiler says:

hetlist.m:123: In declaration of predicate `map_hetlist'/3:
hetlist.m:123:   error: undefined type `[]'/0.
hetlist.m:123: In declaration of predicate `map_hetlist'/3:
hetlist.m:123:   error: undefined type `[|]'/2.
hetlist.m:123: In declaration of predicate `map_hetlist'/3:
hetlist.m:123:   error: undefined type `some'/2.


I've tried various things, and they gave me other errors.

How should I declare this?

Thanks,
Volker
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.