S.apFirst and S.apSecond
See original GitHub issueDoes it make sense to provide the following two functions?
S.maybeFirst returns the first Maybe value only if both arguments are Just, otherwise return Nothing.
S.maybeFirst :: Maybe a -> Maybe b -> Maybe a
> S.maybeFirst(S.Nothing(), S.Nothing())
Nothing()
> S.maybeFirst(S.Just(1), S.Nothing())
Nothing()
> S.maybeFirst(S.Just(1), S.Just('2'))
Just(1)
S.maybeSecond returns the second Maybe value only if both arguments are Just, otherwise return Nothing.
S.maybeSecond :: Maybe a -> Maybe b -> Maybe b
> S.maybeSecond(S.Nothing(), S.Nothing())
Nothing()
> S.maybeSecond(S.Just(1), S.Nothing())
Nothing()
> S.maybeSecond(S.Just(1), S.Just('2'))
Just('2')
Or the above functions can be made by composing existing sanctuary functions? Please advice 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
How to use the parser-ts.parser.apFirst function in parser-ts | Snyk
To help you get started, we've selected a few parser-ts.parser.apFirst examples, based on popular ways it is used in public projects.
Read more >StateReaderObservableEither.ts - fp-ts-rxjs
Apply a function to an argument under a type constructor. Signature. export declare const ap: <S, ...
Read more >tree-shaking-test fp-ts build output · GitHub
s = function(n) {. return "function" == typeof n.promap;. } ... S.alt,. S.ap,. S.apFirst,. S.apSecond,. S.chain,. S.chainFirst,. S.duplicate,. S.extend,.
Read more >fp-ts - UNPKG
32, export interface StateReaderTaskEither<S, R, E, A> {. 33, (s: S): ... R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>,...
Read more >Arithmetic Progression (AP) - Formula, nth Term, Sum, Examples
The sum of first n terms of an arithmetic progression when the n th term is NOT known is S ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
something like this shuold do the trick
apFirst apSecond sounds good, we could also add same for ‘>>’ and ‘<<’ as chain… Maybe they could be decleared in s-type-classes?