funcool / funcool/cats

<*> does not invoke a function when the third argument is supplied

Open
#181 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
970
Forks
68
PR merge metrics
No merged PRs in 30d

Description

Currently,

```
(m/<*> (fn [_] inc) inc 1)
=>
#object[cats.builtin$reify__1037$fn__1038
0x5ef84c83
"cats.builtin$reify__1037$fn__1038@5ef84c83"]
((m/<*> (fn [_] inc) inc) 1)
=> 3
```

Ideally,

```
(<*> (fn [_] inc) inc 1)
=> 3
```

Haskell's definition takes three arguments although it doesn't matter how it's defined in Haskell as it's curried.
https://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.Base.html#line-641

In order to accept the third argument, -fppply of cats.builtin's function-context can be modified like this:

```
(-fapply [_ self av]
(if (fn? av)
(fn [x] ((self x) (av x)))
(self av)))
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at cats.builtin's function-context and inspect the -fapply entry point shown in the issue. Reproduce both examples, then verify the three-argument form evaluates to 3 and add regression coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.