# By-module operators

**URL:** <https://swi-prolog.discourse.group/t/by-module-operators/289>\
**Category:** General\
**Created:** [February 17, 2019, 7:23am UTC](https://swi-prolog.discourse.group/t/by-module-operators/289 "2019-02-17T07:23:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anniepoo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/anniepoo/32/12_2.png) [@anniepoo](https://swi-prolog.discourse.group/u/anniepoo)\
**Post date:** [February 17, 2019, 7:23am UTC](https://swi-prolog.discourse.group/t/by-module-operators/289/1 "2019-02-17T07:23:39Z")

</div>

So, importing a module with many predicates, many of which I need.

But darn it, it also exports an operator, and I need the operator.  
so I have to list explicitly all the predicates, just so I can include the operator.

Is there a workaround?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 17, 2019, 2:03pm UTC](https://swi-prolog.discourse.group/t/by-module-operators/289/2 "2019-02-17T14:03:45Z")

</div>

? You either use `use_module/1` and get all predicates and operators. That is what I usually do, unless conflicts arise or are likely. Or, you use `use_module/2` and define the predicates and operators you want. You can import a predicate without its operator or the other way around. They are completely unrelated. Importing operators allows for patterns, typically `op(_,_,<name>)` or `op(_,_,_)` to get either a specific operator, but regardless of its priority and association or all operators from the module.

---

<div class="post-metadata">

**Author:** ![anniepoo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/anniepoo/32/12_2.png) [@anniepoo](https://swi-prolog.discourse.group/u/anniepoo)\
**Post date:** [February 17, 2019, 2:14pm UTC](https://swi-prolog.discourse.group/t/by-module-operators/289/3 "2019-02-17T14:14:19Z")

</div>

Oh, wait, the docs say use\_module/1 does NOT give you the operators.  
Hence my gunging (and confusion).

---

<div class="post-metadata">

**Author:** ![anniepoo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/anniepoo/32/12_2.png) [@anniepoo](https://swi-prolog.discourse.group/u/anniepoo)\
**Post date:** [February 17, 2019, 2:20pm UTC](https://swi-prolog.discourse.group/t/by-module-operators/289/4 "2019-02-17T14:20:27Z")

</div>

I chased to load\_file import option to get the syntax.

If Import equals `all` , all operators are imported as well. Otherwise, operators are _not_ imported. Operators can be imported selectively by adding terms `op(Pri,Assoc,Name)` to the Import list. If such a term is encountered, all exported operators that unify with this term are imported. Typically, this construct will be used with all arguments unbound to import all operators or with only Name bound to import a particular operator.

wasn’t obvious that use\_module/1 was ‘all’  
8cD
