import * as logger from 'fp-ts/lib/Console'
import { constVoid, Lazy } from 'fp-ts/lib/function'
import { IO, io } from 'fp-ts/lib/IO'
export * from 'fp-ts/lib/IO'
/**
* Run IO
*/
export const runIO = (x: IO): A => x()
/**
* Returns the run function for an IO
*/
export const constRunIO = (x: IO): Lazy => x
/**
* IO constructor function
*
*/
export const newIO = (f: Lazy): IO => f
/**
* noOp IO function
*/
export const noOpIO = newIO(constVoid)
export const logIO = (
cb: (value: T) => unknown,
logLevel: 'error' | 'info' | 'log' | 'warn' = 'log',
) => (value: T): T => io.map(logger[logLevel](cb(value)), () => value)()
export const tapIO = (logIO_: (value: T) => IO) => (value: T): T =>
io.map(logIO_(value), () => value)()