[mercury-users] mode/inst etc
Tomas By
tomas at basun.net
Thu Jan 3 03:11:10 AEDT 2008
Hello,
Suppose I have a type:
:- type tree(K,V) ---> empty ; tree(K,V,tree(K,V),tree(K,V)).
and a procedure that is only ever called for a non-empty tree:
:- pred dosomething(tree(K,V)::in,K::out,V::out) is det.
I could write
dosomething(tree(K,V,_,_),K,V).
dosomething(empty,_,_) :- error("Tree is empty").
but it would be nicer if I could tell the compiler to not allow the tree
to be empty. Perhaps something like
:- mode intree == in(tree(bound,bound)).
:- pred dosomething(tree(K,V)::intree,K::out,V::out) is det.
Is this possible? What should the code like? (The above does not work)
/Tomas
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list