since import { Applicative3 } from 'fp-ts/lib/Applicative' ; import { Apply3 } from 'fp-ts/lib/Apply' ; import { Either } from 'fp-ts/lib/Either' ; import { identity , Predicate , Refinement } from 'fp-ts/lib/function' ; import { Functor3 } from 'fp-ts/lib/Functor' ; import { IO } from 'fp-ts/lib/IO' ; import { IOEither } from 'fp-ts/lib/IOEither' ; import { Monad3 } from 'fp-ts/lib/Monad' ; import { MonadThrow3 } from 'fp-ts/lib/MonadThrow' ; import { Option } from 'fp-ts/lib/Option' ; import { pipe } from 'fp-ts/lib/pipeable' ; import { State } from 'fp-ts/lib/State' ; import { getStateM } from 'fp-ts/lib/StateT' ; import { Task } from 'fp-ts/lib/Task' ; import * as TE from 'fp-ts/lib/TaskEither' ; import TaskEither = TE . TaskEither ; const T = getStateM ( TE . taskEither ) ; category since export interface StateTaskEither < S , E , A > { ( s ) : TaskEither < E , [ A , S ] > ; } category since export const get = T . get ; category since export const put = T . put ; category since export const modify = T . modify ; category since export const gets = T . gets ; category since export const left = ( e ) => fromTaskEither ( TE . left ( e ) ) ; category since export const right = T . of ; category since export const leftIO = ( me ) => fromTaskEither ( TE . leftIO ( me ) ) ; category since export const rightIO = ( ma ) => fromTaskEither ( TE . rightIO ( ma ) ) ; category since export const leftTask = ( me ) => fromTaskEither ( TE . leftTask ( me ) ) ; category since export const rightTask = ( ma ) => fromTaskEither ( TE . rightTask ( ma ) ) ; category since export const leftState = ( me ) => ( s ) => TE . left ( me ( s ) [ 0 ] ) ; category since export const rightState = T . fromState ; category since export const fromOption = ( onNone ) => ( ma ) => ma . _tag === 'None' ? left ( onNone ( ) ) : right ( ma . value ) ; category since export const fromEither = ( ma ) => ma . _tag === 'Left' ? left ( ma . left ) : right ( ma . right ) ; category since export const fromIOEither = ( ma ) => fromTaskEither ( TE . fromIOEither ( ma ) ) ; category since export const fromTaskEither = T . fromM ; category since export const fromEitherK = ( f ) => ( ... a ) => fromEither ( f ( ... a ) ) ; category since export const fromIOEitherK = ( f ) => ( ... a ) => fromIOEither ( f ( ... a ) ) ; category since export const fromTaskEitherK = ( f ) => ( ... a ) => fromTaskEither ( f ( ... a ) ) ; category since export const fromPredicate = < E , A > ( predicate , onFalse ) => < R > ( a ) : StateTaskEither < R , E , A > => predicate ( a ) ? right ( a ) : left ( onFalse ( a ) ) ; category since export const filterOrElse = < E , A > ( predicate , onFalse ) => < R > ( ma ) : StateTaskEither < R , E , A > => T . chain ( ma , ( a ) => ( predicate ( a ) ? right ( a ) : left ( onFalse ( a ) ) ) ) ; category since export const map = ( f ) => ( fa ) => T . map ( fa , f ) ; category since export const ap = ( fa ) => ( fab ) => T . ap ( fab , fa ) ; category since export const apFirst = < R , E , B > ( fb ) => < A > ( fa ) : StateTaskEither < R , E , A > => pipe ( fa , map ( ( a ) => ( _ ) => a ) , ap ( fb ) ) ; category since export const apSecond = < R , E , B > ( fb ) => < A > ( fa ) : StateTaskEither < R , E , B > => pipe ( fa , map ( ( ) => ( b ) => b ) , ap ( fb ) ) ; category since export const of = right ; category since export const chain = ( f ) => ( ma ) => T . chain ( ma , f ) ; category since export const chainFirst = ( f ) => ( ma ) => T . chain ( ma , ( a ) => T . map ( f ( a ) , ( ) => a ) ) ; category since export const chainEitherK = < E , A , B > ( f ) : ( < S > ( ma : StateTaskEither < S , E , A > ) => StateTaskEither < S , E , B > ) => chain < any , E , A , B > ( fromEitherK ( f ) ) ; category since export const chainIOEitherK = < E , A , B > ( f ) : ( < S > ( ma : StateTaskEither < S , E , A > ) => StateTaskEither < S , E , B > ) => chain < any , E , A , B > ( fromIOEitherK ( f ) ) ; category since export const chainTaskEitherK = < E , A , B > ( f ) : ( < S > ( ma : StateTaskEither < S , E , A > ) => StateTaskEither < S , E , B > ) => chain < any , E , A , B > ( fromTaskEitherK ( f ) ) ; category since export const flatten = ( mma ) => T . chain ( mma , identity ) ; category since export const URI = 'StateTaskEither' ; category since export type URI = typeof URI ; declare module 'fp-ts/lib/HKT' { interface URItoKind3 < R , E , A > { StateTaskEither : StateTaskEither < R , E , A > ; } } category since export const Functor = { URI , map : T . map } ; category since export const Applicative = { URI , map : T . map , ap : T . ap , of } ; category since export const Apply = { URI , map : T . map , ap : T . ap } ; category since export const Monad = { URI , map : T . map , ap : T . ap , chain : T . chain , of } ; category since export const stateTaskEither = { URI , map : T . map , of : right , ap : T . ap , chain : T . chain , throwError : left } ; category since export const stateTaskEitherSeq = { ... stateTaskEither , ap : ( mab , ma ) => T . chain ( mab , ( f ) => T . map ( ma , f ) ) } ; since export const evalState = T . evalState ; since export const execState = T . execState ; since export const run = ( ma , s ) => ma ( s ) ( ) ;