diff --git a/src/lib/painter/lifecycle.ts b/src/lib/painter/lifecycle.ts index a55a8fa..dd65069 100644 --- a/src/lib/painter/lifecycle.ts +++ b/src/lib/painter/lifecycle.ts @@ -1,20 +1,8 @@ import { type CursorPos } from 'node:readline' import type { Either } from '../util/basic/either' -import { - DoOption, - getOrElse, - none, - type Option, - some, -} from '../util/basic/option' -import { hasTag, pipe, type Tag } from '../util/basic/utility' -import { - type CanvasEnd, - type CanvasOrigin, - cursorPos, - end, - origin, -} from './canvas' +import { none, type Option, some } from '../util/basic/option' +import { type Tag } from '../util/basic/utility' +import { type CanvasEnd, type CanvasOrigin, end, origin } from './canvas' interface PainterExit extends Tag<'PainterExit'> { value: Either @@ -67,51 +55,3 @@ export { type PainterTask, task, } - -// -// testing -// - -type TestEffect = (x: PainterTask<{message: Option}>) => PainterTask< - {message: Option} -> -const testEffect: PainterEffect<{message: string, counter: number}> = x => { - const state = DoOption.start() - .bind('state', x.task.state) - .doL(ctx => { - console.log('Message:', ctx.state.message) - return some(undefined) - }) - .doL(ctx => { - console.log('Counter:', ctx.state.counter) - return some(undefined) - }) - .return(ctx => - (ctx.state.counter < 100000) - ? {...ctx.state, counter: ctx.state.counter + 1} - : none - ) - if (pipe(state, getOrElse(none), hasTag('None'))) return {_tag: 'PainterExit'} - - return task(x.task.origin.value, x.task.end.value)( - x.task.effect, - getOrElse(none)(state), - ) -} - -const textTask = task<{message: string, counter: number}>( - cursorPos(2)(0), - cursorPos(4)(0), -)( - testEffect, - { - _tag: 'PainterState', - message: 'test message', - counter: 1, - }, -) -const testFn = (x: PainterTask | PainterExit) => { - return hasTag('PainterExit')(x) ? 'Exit' : testFn(x.task.effect(x)) -} - -testFn(textTask)