20 lines
523 B
JavaScript
20 lines
523 B
JavaScript
/**
|
|
* @since 1.2.0
|
|
*/
|
|
import { At, Lens } from '..';
|
|
import * as S from 'fp-ts/es6/Set';
|
|
/**
|
|
* @category constructor
|
|
* @since 1.2.0
|
|
*/
|
|
export function atSet(E) {
|
|
var elemE = S.elem(E);
|
|
var insertE = S.insert(E);
|
|
var removeE = S.remove(E);
|
|
return new At(function (at) {
|
|
var insertEAt = insertE(at);
|
|
var removeEAt = removeE(at);
|
|
return new Lens(function (s) { return elemE(at, s); }, function (a) { return function (s) { return (a ? insertEAt(s) : removeEAt(s)); }; });
|
|
});
|
|
}
|