[m-dev.] bimap

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Jan 8 18:30:25 AEDT 2004


On 08-Jan-2004, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> It would be a good idea to actually document the semantics of bimap__set
> and the other undocumented procedures in bimap.

I agree. That is one reason why I asked about the semantics being relied
upon, as opposed to what is done or what is already documented.

> An alternative that would be slightly better for backwards compatibility
> export bimap/2 as a function (with both forwards and reverse modes),
> rather than a constructor, but to then use `pragma obsolete' to deprecate it.
> This would require renaming the bimap/2 constructor, e.g to bimap_ctor/2
> or mk_bimap/2.

The problem is that taking two existing maps and simply joining them to
make a bimap is fundamentally unsafe. To make it safe, you would have to check
that every entry x->y in the forward map is matched by a x<-y entry in the
reverse map. It would be simpler to add an semidet operation to convert
a map to a bimap, which would fail if the map isn't a bijection. We could
add such an operation if needed, but so far I haven't seen a need.

Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list