Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14x 1x 11x 11x 11x 11x 11x 11x 1x 12x 12x 12x 12x 1x 8x 8x 8x 8x 1x 8x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {unwords} from '#String'
import {Array, Equivalence as EQ, String} from 'effect'
import {
VStruts,
type HStrut,
type HStruts,
type Struts,
type VStrut,
} from './index.js'
const arrayStringEquivalence = Array.getEquivalence(String.Equivalence)
/**
* Equivalence for horizontal struts.
* @category drawing
* @function
*/
export const HStrutEquivalence: EQ.Equivalence<HStrut> = EQ.struct({
prefix: String.Equivalence,
body: arrayStringEquivalence,
suffix: String.Equivalence,
})
/**
* Equivalence for vertical struts.
* @category drawing
* @function
*/
export const VStrutEquivalence: EQ.Equivalence<VStrut> = EQ.struct({
prefix: arrayStringEquivalence,
body: arrayStringEquivalence,
suffix: arrayStringEquivalence,
})
/**
* @category drawing
* @function
*/
export const showHStrut = ({prefix, body, suffix}: HStrut): string =>
`⊦${prefix}«${unwords.quote.fancy(body)}»${suffix}`
/**
* @category drawing
* @function
*/
export const showVStrut = ({prefix, body, suffix}: VStrut): string =>
unwords.rest(
'⊥',
unwords.comma(prefix),
`«${unwords.quote.fancy(body)}»`,
unwords.comma(suffix),
)
/**
* @category drawing
* @function
*/
export const showHStruts = ({right, left}: HStruts): string =>
unwords.rest(
`←${showHStrut(left)}`,
...(HStrutEquivalence(left, right) ? [] : [`→${showHStrut(right)}`]),
)
/**
* @category drawing
* @function
*/
export const showVStruts = ({top, bottom}: VStruts): string =>
unwords.rest(
`↑${showVStrut(top)}`,
...(VStrutEquivalence(top, bottom) ? [] : [`↓${showVStrut(bottom)}`]),
)
/**
* @category drawing
* @function
*/
export const showStruts = ({top, right, bottom, left}: Struts): string =>
unwords.rest(showHStruts({left, right}), showVStruts({top, bottom}))
/**
* @category drawing
* @function
*/
export const HStrutsEquivalence: EQ.Equivalence<HStruts> = EQ.struct({
left: HStrutEquivalence,
right: HStrutEquivalence,
})
/**
* @category drawing
* @function
*/
export const VStrutsEquivalence: EQ.Equivalence<VStruts> = EQ.struct({
top: VStrutEquivalence,
bottom: VStrutEquivalence,
})
/**
* @category drawing
* @function
*/
export const StrutsEquivalence: EQ.Equivalence<Struts> = EQ.struct({
top: VStrutEquivalence,
bottom: VStrutEquivalence,
left: HStrutEquivalence,
right: HStrutEquivalence,
})
|