imeraj

imeraj

Advanced Functional Programming with Elixir: Problem Running Code Example

I am reading this book with great enthusiasm.

So far the code works great but while running the examples in Predicates That Span Contexts section I am encountering some function arity errors as below -

iex(13)> FunPark.Ride.eligible?(alice, tea_cup)
** (FunctionClauseError) no function clause matching in FunPark.Monoid.FunPark.Monoid.PredAll.wrap/2

    The following arguments were given to FunPark.Monoid.FunPark.Monoid.PredAll.wrap/2:

        # 1
        %FunPark.Monoid.PredAll{
          value: &FunPark.Monoid.PredAll.default_pred?/1
        }

        # 2
        #Function<1.2796843/2 in FunPark.Ride.tall_enough?>

    Attempted function clauses (showing 1 out of 1):

        def wrap(%FunPark.Monoid.PredAll{}, value) when is_function(value, 1)

Apparently, we are passing two arguments instead of one here -

def eligible?(%Patron{} = patron, %__MODULE__{} = ride),
    do: p_all([&tall_enough?/2, &old_enough?/2]).(patron, ride)

I ran the book’s sample code and it works fine. But it has code with curry.

I am wondering if the example code from this section is supposed to run without curry as I am typing in the code as I go.

Thanks!

Where Next?

Popular Pragmatic Bookshelf topics Top

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
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |&gt; handle_event() |&gt; render() but the correc...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New

Sub Categories: