funcool / funcool/cats

<*> throws an exception if the first argument is not a higher-order function

Open
#182 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,

```
((<*> + inc) 1)
CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn, compiling:
```

It can be worked around by calling <*> like this:

```
((<*> (m/curry 2 +) inc) 1)
=> 3
```

Here is an alternative implementation of -fapply for function-context in cats.builtin

```
(-fapply [_ self av]
(fn [x] (((m/curry 2 self) x) (av x))))
```

With this implementation,

```
((<*> + inc) 1)
=> 3
```

This implementation doesn't work if the first argument of <*> is a higher-order function.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.