Remove tests, clean up imports
This commit is contained in:
parent
cafc857e56
commit
e9216cc3e4
@ -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<E> extends Tag<'PainterExit'> {
|
||||
value: Either<E, Error>
|
||||
@ -67,51 +55,3 @@ export {
|
||||
type PainterTask,
|
||||
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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user