We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modifyF
Lens
Optional
Ix
For now, monocle-ts only support modifyF in Traversal(even in v3.0.0 branch).
monocle-ts
Traversal
But modifyF is required to make modify context, for example: implementation:
import * as M from 'monocle-ts'; import * as F from 'fp-ts'; export const modifyF4Lens = <F extends F.hkt.URIS>( functor: F.functor.Functor1<F> ) => <A>(f: (a: A) => F.hkt.Kind<F, A>) => <S>(lens: M.Lens<S, A>) => ( s: S ): F.hkt.Kind<F, S> => { return F.function.pipe(lens.get(s), f, fa => functor.map(fa, (a: A) => lens.set(a)(s)) ); };
testing:
import * as F from 'fp-ts'; import * as M from 'monocle-ts'; import {modifyF4Lens} from './index'; describe('modify f', () => { test('modifyF in Lens', () => { interface Account { name: string; } const nameM: M.Lens<Account, string> = M.Lens.fromProp<Account>()('name'); const nameModified = modifyF4Lens(F.option.Functor)(name => F.option.some(`${name}Modified`) )(nameM)({name: 'monocle'}); expect(nameModified).toEqual(F.option.some({name: 'monocleModified'})); }); });
The text was updated successfully, but these errors were encountered:
@jituanlin I will add modifyF to the experimental modules
Sorry, something went wrong.
add modifyF, closes #149
10cf4e4
5c9d692
gcanti
No branches or pull requests
For now,
monocle-ts
only supportmodifyF
inTraversal
(even in v3.0.0 branch).But
modifyF
is required to make modify context, for example:implementation:
testing:
The text was updated successfully, but these errors were encountered: