[m-users.] problem with unique modes

Mark Brown mark at mercurylang.org
Tue Jun 16 08:37:59 AEST 2015


On Tue, Jun 16, 2015 at 4:09 AM, Matthias Güdemann
<matthias at guedemann.org> wrote:
> Hi,
>
> I defined a data type which holds two state variables, like in
>
> ,----
> | :- type state --->
> |         state(
> |            substate1 :: state1,
> |            substate2 :: state2
> |            ).
> `----
>
> Now I'd like to have predicates that advance a 'state' by advancing the
> substates, i.e. a predicate has 'state::di' and 'state::uo' arguments
> and calls others with analogous arguments for substate1 and substate2.
>
> The problem is that I get lots of unique mode errors. Is this because I
> am doing it wrong? Or is it because of the limits described in the
> documentation[1]?

As it says, you will get unique mode errors when you try to get a
unique field of a unique data structure.

>
> My principal goal is to have a list of states that are advanced
> iteratively by a predicate that takes a list of 'di' inputs and creates
> a list of 'uo' moded outputs. How is this handled in general?

builtin.unsafe_promise_unique is the workaround.

Cheers,
Mark.

>
> Best regards,
> Matthias
>
> Footnotes:
> [1]  http://mercurylang.org/information/doc-release/mercury_ref/Limitations-of-the-current-implementation.html#Limitations-of-the-current-implementation
>
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://www.mercurylang.org/lists/listinfo/users



More information about the users mailing list