Translating (+) <$> (*2) <*> (+10)
#1801
Answered
by
samhh
THOUSAND-SKY
asked this question in
Q&A
-
But what is |
Beta Was this translation helpful? Give feedback.
Answered by
samhh
Oct 24, 2022
Replies: 1 comment 1 reply
-
I think that example relies on the applicative instance for import { pipe } from 'fp-ts/function'
import * as Fn from 'fp-ts-std/Function'
import * as Num from 'fp-ts-std/Number'
export const f = pipe(
Fn.of(Num.add),
Fn.ap(Num.multiply(2)),
Fn.ap(Num.add(10)),
) Here |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
THOUSAND-SKY
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that example relies on the applicative instance for
(->)
. fp-ts-std defines these instances, for which the following appears to behave equivalently:Here
pure (+)
translates toFn.of(Num.add)
.