derw
Version:
An Elm-inspired language that transpiles to TypeScript
144 lines (143 loc) • 3.64 kB
TypeScript
import { BlockKinds, Block, TypedBlock, Module } from "./types";
export { blockKind };
export { createUnparsedBlock };
export { intoBlocks };
export { typeBlocks };
export { exportTests };
type Ok<value> = {
kind: "Ok";
value: value;
};
declare function Ok<value>(args: {
value: value;
}): Ok<value>;
type Err<error> = {
kind: "Err";
error: error;
};
declare function Err<error>(args: {
error: error;
}): Err<error>;
type Result<error, value> = Ok<value> | Err<error>;
type ImportBlock = {
kind: "ImportBlock";
lineStart: number;
lines: string[];
};
declare function ImportBlock(args: {
lineStart: number;
lines: string[];
}): ImportBlock;
type ExportBlock = {
kind: "ExportBlock";
lineStart: number;
lines: string[];
};
declare function ExportBlock(args: {
lineStart: number;
lines: string[];
}): ExportBlock;
type UnionTypeBlock = {
kind: "UnionTypeBlock";
lineStart: number;
lines: string[];
};
declare function UnionTypeBlock(args: {
lineStart: number;
lines: string[];
}): UnionTypeBlock;
type UnionUntaggedTypeBlock = {
kind: "UnionUntaggedTypeBlock";
lineStart: number;
lines: string[];
};
declare function UnionUntaggedTypeBlock(args: {
lineStart: number;
lines: string[];
}): UnionUntaggedTypeBlock;
type TypeAliasBlock = {
kind: "TypeAliasBlock";
lineStart: number;
lines: string[];
};
declare function TypeAliasBlock(args: {
lineStart: number;
lines: string[];
}): TypeAliasBlock;
type TypeclassBlock = {
kind: "TypeclassBlock";
lineStart: number;
lines: string[];
};
declare function TypeclassBlock(args: {
lineStart: number;
lines: string[];
}): TypeclassBlock;
type ImplBlock = {
kind: "ImplBlock";
lineStart: number;
lines: string[];
};
declare function ImplBlock(args: {
lineStart: number;
lines: string[];
}): ImplBlock;
type FunctionBlock = {
kind: "FunctionBlock";
lineStart: number;
lines: string[];
};
declare function FunctionBlock(args: {
lineStart: number;
lines: string[];
}): FunctionBlock;
type ConstBlock = {
kind: "ConstBlock";
lineStart: number;
lines: string[];
};
declare function ConstBlock(args: {
lineStart: number;
lines: string[];
}): ConstBlock;
type CommentBlock = {
kind: "CommentBlock";
lineStart: number;
lines: string[];
};
declare function CommentBlock(args: {
lineStart: number;
lines: string[];
}): CommentBlock;
type MultilineCommentBlock = {
kind: "MultilineCommentBlock";
lineStart: number;
lines: string[];
};
declare function MultilineCommentBlock(args: {
lineStart: number;
lines: string[];
}): MultilineCommentBlock;
type UnknownBlock = {
kind: "UnknownBlock";
lineStart: number;
lines: string[];
};
declare function UnknownBlock(args: {
lineStart: number;
lines: string[];
}): UnknownBlock;
type UnparsedBlock = ImportBlock | ExportBlock | UnionTypeBlock | UnionUntaggedTypeBlock | TypeAliasBlock | TypeclassBlock | ImplBlock | FunctionBlock | ConstBlock | CommentBlock | MultilineCommentBlock | UnknownBlock;
declare function blockKind(block: string): Result<string, BlockKinds>;
declare function createUnparsedBlock(blockKind: BlockKinds, lineStart: number, lines: string[]): UnparsedBlock;
declare function intoBlocks(body: string): UnparsedBlock[];
declare function typeBlocks(blocks: Block[]): TypedBlock[];
type Export = {
kind: "Export";
names: string[];
};
declare function Export(args: {
names: string[];
}): Export;
type MyExport = Export;
declare function exportTests(module: Module): MyExport;