shotleybuilder

shotleybuilder

Exploring Graphs with Elixir: service contexts p.92-93

The book states “define the function graph_service/0 within the body of the using/1 macro
in the GraphCommons.Graph module”

The code download shows this:

defmacro using(opts) do
graph_type = Keyword.get(opts, :graph_type)
graph_module = Keyword.get(opts, :graph_module)

quote do

  # other (listings, new_graph) functions here

  def read_graph(graph_file),
    do: GraphCommons.Graph.read_graph(graph_file, unquote(graph_type))

  def write_graph(graph_data, graph_file),
    do: GraphCommons.Graph.write_graph(graph_data, graph_file,
    unquote(graph_type))
end

end

def graph_service(), do: unquote(graph_module)

def gs() do
graph_service()
graph_info()
end

I’ve not been able to work through the error here and obtain the result shown in the book, namely:

iex> graph_service PropertyGraph
PropertyGraph

So, no solution from me, but I sense there’s more than a one problem here

First Post!

shotleybuilder

shotleybuilder

Okay, this was simply a case of moving
def graph_service(), do: unquote(graph_module)
into the macro.

The error is in the code download

Where Next?

Popular Pragmatic Bookshelf topics Top

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1030 17300 381
New
AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New

Sub Categories: