MCPcopy
hub / github.com/Effect-TS/effect / prettyTypes

Function prettyTypes

packages/printer/examples/main.ts:5–17  ·  view source on GitHub ↗
(types: ReadonlyArray<string>)

Source from the content-addressed store, hash-verified

3import { pipe } from "effect/Function"
4
5const prettyTypes = (types: ReadonlyArray<string>): Doc.Doc<never> => {
6 const symbolDocuments = pipe(
7 Array.makeBy(types.length - 1, () => Doc.text("->")),
8 Array.prepend(Doc.text("::"))
9 )
10 const typeDocuments = types.map(Doc.text)
11 const documents = Array.zipWith(
12 symbolDocuments,
13 typeDocuments,
14 (left, right) => Doc.catWithSpace(left, right)
15 )
16 return Doc.align(Doc.seps(documents))
17}
18
19const prettyDeclaration = (name: string, types: ReadonlyArray<string>): Doc.Doc<never> =>
20 Doc.catWithSpace(Doc.text(name), prettyTypes(types))

Callers 1

prettyDeclarationFunction · 0.85

Calls 3

mapMethod · 0.65
pipeFunction · 0.50
textMethod · 0.45

Tested by

no test coverage detected