since import { Applicative , Applicative1 , Applicative2 , Applicative2C , Applicative3 } from 'fp-ts/lib/Applicative' ; import { Category2 } from 'fp-ts/lib/Category' ; import * as C from 'fp-ts/lib/Const' ; import { Either } from 'fp-ts/lib/Either' ; import { flow , identity , Predicate , Refinement } from 'fp-ts/lib/function' ; import { HKT , Kind , Kind2 , Kind3 , URIS , URIS2 , URIS3 } from 'fp-ts/lib/HKT' ; import { Monoid } from 'fp-ts/lib/Monoid' ; import { Option } from 'fp-ts/lib/Option' ; import { pipe } from 'fp-ts/lib/pipeable' ; import * as RA from 'fp-ts/lib/ReadonlyArray' ; import { ReadonlyNonEmptyArray } from 'fp-ts/lib/ReadonlyNonEmptyArray' ; import { ReadonlyRecord } from 'fp-ts/lib/ReadonlyRecord' ; import { Semigroupoid2 } from 'fp-ts/lib/Semigroupoid' ; import { Traversable , Traversable1 , Traversable2 , Traversable3 } from 'fp-ts/lib/Traversable' ; import * as _ from './internal' ; import { Iso } from './Iso' ; import { Lens } from './Lens' ; import { Optional } from './Optional' ; import { Prism } from './Prism' ; category since export interface ModifyF < S , A > { < F extends URIS3 > ( F ) : < R , E > ( f : ( a : A ) => Kind3 < F , R , E , A > ) => ( s : S ) => Kind3 < F , R , E , S > ; < F extends URIS2 > ( F ) : < E > ( f : ( a : A ) => Kind2 < F , E , A > ) => ( s : S ) => Kind2 < F , E , S > ; < F extends URIS2 , E > ( F ) : ( f : ( a : A ) => Kind2 < F , E , A > ) => ( s : S ) => Kind2 < F , E , S > ; < F extends URIS > ( F ) : ( f : ( a : A ) => Kind < F , A > ) => ( s : S ) => Kind < F , S > ; < F > ( F ) : ( f : ( a : A ) => HKT < F , A > ) => ( s : S ) => HKT < F , S > ; } category since export interface Traversal < S , A > { readonly modifyF : ModifyF < S , A > ; } category since export const traversal = _ . traversal ; category since export const id = < S > ( ) : Traversal < S , S > => traversal ( < F > ( _ ) => ( f ) => f ) ; category since export const fromTraversable = _ . fromTraversable ; category since export const compose = _ . traversalComposeTraversal ; category since export const composeTraversal = compose ; category since export const composeIso = flow ( _ . isoAsTraversal , compose ) ; category since export const composeLens = flow ( _ . lensAsTraversal , _ . traversalComposeTraversal ) ; category since export const composePrism = flow ( _ . prismAsTraversal , _ . traversalComposeTraversal ) ; category since export const composeOptional = flow ( _ . optionalAsTraversal , _ . traversalComposeTraversal ) ; category since export const modify = < A > ( f ) => < S > ( sa ) : ( ( s : S ) => S ) => sa . modifyF ( _ . ApplicativeIdentity ) ( f ) ; category since export const set = < A > ( a ) : ( < S > ( sa : Traversal < S , A > ) => ( s : S ) => S ) => modify ( ( ) => a ) ; category since export const fromNullable = < S , A > ( sa ) : Traversal < S , NonNullable < A > > => composePrism ( _ . prismFromNullable < A > ( ) ) ( sa ) ; category since export function filter < A , B extends A > ( refinement ) ; export function filter < A > ( predicate ) ; export function filter < A > ( predicate ) { return compose ( _ . prismAsTraversal ( _ . prismFromPredicate ( predicate ) ) ) ; } category since export const prop = < A , P extends keyof A > ( prop ) : ( < S > ( sa : Traversal < S , A > ) => Traversal < S , A [ P ] > ) => compose ( pipe ( _ . lensId < A > ( ) , _ . lensProp ( prop ) , _ . lensAsTraversal ) ) ; category since export const props = < A , P extends keyof A > ( ... props ) : ( < S > ( sa : Traversal < S , A > ) => Traversal < S , { [ K in P ] : A [ K ] ; } > ) => compose ( pipe ( _ . lensId < A > ( ) , _ . lensProps ( ... props ) , _ . lensAsTraversal ) ) ; category since export const component = < A extends ReadonlyArray < unknown > , P extends keyof A > ( prop ) : ( < S > ( sa : Traversal < S , A > ) => Traversal < S , A [ P ] > ) => compose ( pipe ( _ . lensId < A > ( ) , _ . lensComponent ( prop ) , _ . lensAsTraversal ) ) ; category since export const index = ( i ) => < S , A > ( sa ) : Traversal < S , A > => pipe ( sa , compose ( _ . optionalAsTraversal ( _ . indexReadonlyArray < A > ( ) . index ( i ) ) ) ) ; category since export const indexNonEmpty = index ; category since export const key = ( key ) => < S , A > ( sa ) : Traversal < S , A > => pipe ( sa , compose ( _ . optionalAsTraversal ( _ . indexReadonlyRecord < A > ( ) . index ( key ) ) ) ) ; category since export const atKey = ( key ) => < S , A > ( sa ) : Traversal < S , Option < A > > => pipe ( sa , compose ( _ . lensAsTraversal ( _ . atReadonlyRecord < A > ( ) . at ( key ) ) ) ) ; category since export const some = compose ( _ . prismAsTraversal ( _ . prismSome ( ) ) ) ; category since export const right = compose ( _ . prismAsTraversal ( _ . prismRight ( ) ) ) ; category since export const left = compose ( _ . prismAsTraversal ( _ . prismLeft ( ) ) ) ; category since export const traverse = _ . traversalTraverse ; category since export function findFirst < A , B extends A > ( refinement ) ; export function findFirst < A > ( predicate ) ; export function findFirst < A > ( predicate ) { return composeOptional ( _ . optionalFindFirst ( predicate ) ) ; } category since export function findFirstNonEmpty < A , B extends A > ( refinement ) ; export function findFirstNonEmpty < A > ( predicate ) ; export function findFirstNonEmpty < A > ( predicate ) { return findFirst ( predicate ) ; } category since export const foldMap = < M > ( M ) => < A > ( f ) => < S > ( sa ) : ( ( s : S ) => M ) => sa . modifyF ( C . getApplicative ( M ) ) ( ( a ) => C . make ( f ( a ) ) ) ; category since export const fold = < A > ( M ) : ( < S > ( sa : Traversal < S , A > ) => ( s : S ) => A ) => foldMap ( M ) ( identity ) ; category since export const getAll = < S > ( s ) => < A > ( sa ) : ReadonlyArray < A > => foldMap ( RA . getMonoid < A > ( ) ) < A > ( RA . of ) ( sa ) ( s ) ; category since export const URI = 'monocle-ts/Traversal' ; category since export type URI = typeof URI ; declare module 'fp-ts/lib/HKT' { interface URItoKind2 < E , A > { readonly [ URI ] : Traversal < E , A > ; } } category since export const Semigroupoid = { URI , compose : ( ab , ea ) => compose ( ab ) ( ea ) } ; category since export const Category = { URI , compose : Semigroupoid . compose , id } ;