[m-users.] Mercury to c# workflow?
Julien Fischer
jfischer at opturion.com
Mon Jan 17 00:09:47 AEDT 2022
Hi David,
On Sat, 15 Jan 2022, David Epstein wrote:
> Thanks again for the C# example in the repo! I think my use case for "assert"
> and "retract" is the exact one described on page 4 of the Prolog to Mercury
> transition guide, "Most uses of assert and retract in Prolog programs are not
> actually intended to alter the program. Their purpose is just to maintain a
> set of facts, with semantically separate sets of facts being stored in
> separate predicates." I won't need to define new predicates or rules during
> runtime, but I may want to change the assignment of terms to predicates, for
> example, whether "is_citrus(orange)" from the C# side. My questions below
> relate to this need:
>
> (1) Would I just build a list of (predefined) terms of type fruit and send
> them to "is_citrus(fruit::in)" like you did with "cube(int)"?
I'm not sure what you mean by the reference to "cube(int)", there is
no list passed to it.
> (2) How would I remove one or more assignments, e.g. so the database is silent on whether orange is_citrus?
> (3) How about members of types, could I add the new term "kiwi" to the list
> of type fruit during runtime and have it exported automatically for reference
> in C#?
You cannot modify Mercury types at runtime. You would need to handle things
differently if you did want to be able to define a new kind of fruit at
runtime.
I have attached a small example (similar to the C# interface example) that
defines a Mercury database of fruit, keeping track of whether the fruits in it
are citrus or not. The accompanying C# program manipulates this database using
the predicates and types exported to C# from the Mercury module. It illustrates
one way of achieving the above.
All that said, I think your questions are conflating two issues:
1. The design of your database of (sets of) facts in Mercury and the API
that is used to operate on it.
2. How that API is exported from Mercury to C#.
I suggest focusing on (1), as (2) is mostly straightforward.
Julien.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fruitbowl.tar.gz
Type: application/gzip
Size: 1648 bytes
Desc:
URL: <http://lists.mercurylang.org/archives/users/attachments/20220117/2f5b29ad/attachment-0001.gz>
More information about the users
mailing list