Remove tests, clean up imports

This commit is contained in:
Eric Rumsey 2025-06-02 14:26:57 -05:00
parent cafc857e56
commit e9216cc3e4

View File

@ -1,20 +1,8 @@
import { type CursorPos } from 'node:readline' import { type CursorPos } from 'node:readline'
import type { Either } from '../util/basic/either' import type { Either } from '../util/basic/either'
import { import { none, type Option, some } from '../util/basic/option'
DoOption, import { type Tag } from '../util/basic/utility'
getOrElse, import { type CanvasEnd, type CanvasOrigin, end, origin } from './canvas'
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'
interface PainterExit<E> extends Tag<'PainterExit'> { interface PainterExit<E> extends Tag<'PainterExit'> {
value: Either<E, Error> value: Either<E, Error>
@ -67,51 +55,3 @@ export {
type PainterTask, type PainterTask,
task, task,
} }
//
// testing
//
type TestEffect = (x: PainterTask<{message: Option<string>}>) => PainterTask<
{message: Option<string>}
>
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)