funcool / funcool/cats

replacing <*> with ap for maybe results in an exception

Open
#189 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

> (<*>) = ap, although more efficient implementations may exist
https://wiki.haskell.org/Functor-Applicative-Monad_Proposal#Compatibility_issues

However,
```
(m/<*> (m/<$> (m/curry 2 +) (maybe/just 1)) (maybe/just 2))
=> #
(m/ap (m/<$> (m/curry 2 +) (maybe/just 1)) (maybe/just 2))
CompilerException java.lang.ClassCastException: cats.monad.maybe.Just cannot be cast to clojure.lang.IFn, compiling:
```

```
ap :: (Monad m) => m (a -> b) -> m a -> m b
ap m1 m2 = do { x1 <- m1; x2 <- m2; return (x1 x2) }
```
https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#ap

```
(defn ap
[m1 m2]
(m/mlet [x1 m1
x2 m2]
(m/return (x1 x2))))

(ap (m/<$> (m/curry 2 +) (maybe/just 1)) (maybe/just 2))
=> #
```

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.