How to load xpeg into a Mix project or Elixir script?
I have hit this issue multiple times now when trying to figure out how to make use of Elixir libraries and it seems to me, that it is assumed knowledge how to load a library to make use of it in ones code. However, I do not have this knowledge, aside from knowing that there are use, alias, import and require and one of them is probably the one I should be using. I read in the Elixir docs, that require is needed when a library defines macros, so I assume, that I need to put require Xpeg in my module. However, in another issue (https://github.com/zevv/xpeg/issues/1#issuecomment-1489826779) I read import Xpeg.
Can you add instructions to the readme of this project, that shows the correct way to import xpeg? It would be helpful for Elixir beginners to see not only examples, but also how to import to make those examples work.
(On a more general note: Can you point to a general rule that is true for all libraries installed via mix? Is there a general rule? Or is it always trial and error with libraries in Elixir?)
https://hexdocs.pm/elixir/1.16/alias-require-and-import.html should answer your questions about use vs import
For xpeg, import Xpeg is the right way. I will add this to the example in the README.