since import { Applicative2 } from 'fp-ts/lib/Applicative' ; import { Apply2 } from 'fp-ts/lib/Apply' ; import { identity } from 'fp-ts/lib/function' ; import { Functor2 } from 'fp-ts/lib/Functor' ; import * as I from 'fp-ts/lib/IO' ; import { Monad2 } from 'fp-ts/lib/Monad' ; import { pipe } from 'fp-ts/lib/pipeable' ; import { State } from 'fp-ts/lib/State' ; import { getStateM } from 'fp-ts/lib/StateT' ; import IO = I . IO ; const T = getStateM ( I . io ) ; category since export interface StateIO < S , A > { ( s ) : IO < [ 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 fromIO = T . fromM ; category since export const fromState = T . fromState ; category since export const fromIOK = ( f ) => ( ... a ) => fromIO ( f ( ... 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 = < E , B > ( fb ) => < A > ( fa ) : StateIO < E , A > => pipe ( fa , map ( ( a ) => ( _ ) => a ) , ap ( fb ) ) ; category since export const apSecond = < E , B > ( fb ) => < A > ( fa ) : StateIO < E , B > => pipe ( fa , map ( ( ) => ( b ) => b ) , ap ( fb ) ) ; category since export const of = T . of ; 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 chainIOK = < A , B > ( f ) : ( < R > ( ma : StateIO < R , A > ) => StateIO < R , B > ) => chain < any , A , B > ( fromIOK ( f ) ) ; category since export const flatten = ( mma ) => T . chain ( mma , identity ) ; category since export const URI = 'StateIO' ; category since export type URI = typeof URI ; declare module 'fp-ts/lib/HKT' { interface URItoKind2 < E , A > { StateIO : StateIO < 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 stateIO = { URI , map : T . map , of : T . of , ap : T . ap , chain : T . chain } ; since export const evalState = T . evalState ; since export const execState = T . execState ; since export const run = ( ma , s ) => ma ( s ) ( ) [ 0 ] ;