derw
Version:
An Elm-inspired language that transpiles to TypeScript
546 lines (545 loc) • 10.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenericType = GenericType;
exports.FixedType = FixedType;
exports.ObjectLiteralType = ObjectLiteralType;
exports.FunctionType = FunctionType;
exports.TagArg = TagArg;
exports.Tag = Tag;
exports.UnionType = UnionType;
exports.UnionUntaggedType = UnionUntaggedType;
exports.Property = Property;
exports.TypeAlias = TypeAlias;
exports.TypeclassFunction = TypeclassFunction;
exports.Typeclass = Typeclass;
exports.Impl = Impl;
exports.FunctionArg = FunctionArg;
exports.AnonFunctionArg = AnonFunctionArg;
exports.Value = Value;
exports.Field = Field;
exports.ObjectLiteral = ObjectLiteral;
exports.StringValue = StringValue;
exports.ListValue = ListValue;
exports.ListRange = ListRange;
exports.FormatStringValue = FormatStringValue;
exports.Destructure = Destructure;
exports.Constructor = Constructor;
exports.ElseIfStatement = ElseIfStatement;
exports.IfStatement = IfStatement;
exports.Addition = Addition;
exports.Subtraction = Subtraction;
exports.Multiplication = Multiplication;
exports.Division = Division;
exports.Mod = Mod;
exports.And = And;
exports.Or = Or;
exports.ListPrepend = ListPrepend;
exports.LeftPipe = LeftPipe;
exports.RightPipe = RightPipe;
exports.ModuleReference = ModuleReference;
exports.FunctionCall = FunctionCall;
exports.Lambda = Lambda;
exports.LambdaCall = LambdaCall;
exports.Default = Default;
exports.EmptyList = EmptyList;
exports.ListDestructure = ListDestructure;
exports.Branch = Branch;
exports.CaseStatement = CaseStatement;
exports.Equality = Equality;
exports.InEquality = InEquality;
exports.LessThan = LessThan;
exports.LessThanOrEqual = LessThanOrEqual;
exports.GreaterThan = GreaterThan;
exports.GreaterThanOrEqual = GreaterThanOrEqual;
exports.isSimpleValue = isSimpleValue;
exports.isLeftPipeableExpression = isLeftPipeableExpression;
exports.Function = Function;
exports.Const = Const;
exports.ImportModule = ImportModule;
exports.Import = Import;
exports.Export = Export;
exports.Comment = Comment;
exports.MultilineComment = MultilineComment;
exports.UnparsedBlock = UnparsedBlock;
exports.DoBlock = DoBlock;
exports.Module = Module;
exports.ContextModule = ContextModule;
exports.contextModuleToModule = contextModuleToModule;
function GenericType(name) {
return {
kind: "GenericType",
name,
};
}
function FixedType(name, args) {
return {
kind: "FixedType",
name,
args,
};
}
function ObjectLiteralType(properties) {
return {
kind: "ObjectLiteralType",
properties,
};
}
function FunctionType(args) {
return {
kind: "FunctionType",
args,
};
}
function TagArg(name, type) {
return {
kind: "TagArg",
name,
type,
};
}
function Tag(name, args) {
return {
kind: "Tag",
name,
args,
};
}
function UnionType(type, tags) {
return {
kind: "UnionType",
type,
tags,
};
}
function UnionUntaggedType(type, values) {
return {
kind: "UnionUntaggedType",
type,
values,
};
}
function Property(name, type) {
return {
kind: "Property",
name,
type,
};
}
function TypeAlias(type, properties) {
return {
kind: "TypeAlias",
type,
properties,
};
}
function TypeclassFunction(name, returnType, args) {
return {
kind: "TypeclassFunction",
name,
returnType,
args,
};
}
function Typeclass(name, variables, functions) {
return {
kind: "Typeclass",
name,
variables,
functions,
};
}
function Impl(name, qualifier, functions) {
return {
kind: "Impl",
name,
qualifier,
functions,
};
}
function FunctionArg(name, type) {
return {
kind: "FunctionArg",
name,
type,
};
}
function AnonFunctionArg(index, type) {
return {
kind: "AnonFunctionArg",
index,
type,
};
}
function Value(body) {
return {
kind: "Value",
body,
};
}
function Field(name, value) {
return {
kind: "Field",
name,
value,
};
}
function ObjectLiteral(base, fields) {
return {
kind: "ObjectLiteral",
base,
fields,
};
}
function StringValue(body) {
return {
kind: "StringValue",
body,
};
}
function ListValue(items) {
return {
kind: "ListValue",
items,
};
}
function ListRange(start, end) {
return {
kind: "ListRange",
start,
end,
};
}
function FormatStringValue(body) {
return {
kind: "FormatStringValue",
body,
};
}
function Destructure(constructor, pattern) {
return {
kind: "Destructure",
constructor,
pattern,
};
}
function Constructor(constructor, pattern) {
return {
kind: "Constructor",
constructor,
pattern,
};
}
function ElseIfStatement(predicate, body, letBody) {
return {
kind: "ElseIfStatement",
predicate,
body,
letBody,
};
}
function IfStatement(predicate, ifBody, ifLetBody, elseIf, elseBody, elseLetBody) {
return {
kind: "IfStatement",
predicate,
ifBody,
ifLetBody,
elseIf,
elseBody,
elseLetBody,
};
}
function Addition(left, right) {
return {
kind: "Addition",
left,
right,
};
}
function Subtraction(left, right) {
return {
kind: "Subtraction",
left,
right,
};
}
function Multiplication(left, right) {
return {
kind: "Multiplication",
left,
right,
};
}
function Division(left, right) {
return {
kind: "Division",
left,
right,
};
}
function Mod(left, right) {
return {
kind: "Mod",
left,
right,
};
}
function And(left, right) {
return {
kind: "And",
left,
right,
};
}
function Or(left, right) {
return {
kind: "Or",
left,
right,
};
}
function ListPrepend(left, right) {
return {
kind: "ListPrepend",
left,
right,
};
}
function LeftPipe(left, right) {
return {
kind: "LeftPipe",
left,
right,
};
}
function RightPipe(left, right) {
return {
kind: "RightPipe",
left,
right,
};
}
function ModuleReference(path, value) {
return {
kind: "ModuleReference",
path,
value,
};
}
function FunctionCall(name, args) {
return {
kind: "FunctionCall",
name,
args,
};
}
function Lambda(args, body) {
return {
kind: "Lambda",
args,
body,
};
}
function LambdaCall(lambda, args) {
return {
kind: "LambdaCall",
lambda,
args,
};
}
function Default() {
return {
kind: "Default",
};
}
function EmptyList() {
return {
kind: "EmptyList",
};
}
function ListDestructure(parts) {
return {
kind: "ListDestructure",
parts,
};
}
function Branch(pattern, body, letBody) {
return {
kind: "Branch",
pattern,
body,
letBody,
};
}
function CaseStatement(predicate, branches) {
return {
kind: "CaseStatement",
predicate,
branches,
};
}
function Equality(left, right) {
return {
kind: "Equality",
left: left,
right,
};
}
function InEquality(left, right) {
return {
kind: "InEquality",
left,
right,
};
}
function LessThan(left, right) {
return {
kind: "LessThan",
left,
right,
};
}
function LessThanOrEqual(left, right) {
return {
kind: "LessThanOrEqual",
left,
right,
};
}
function GreaterThan(left, right) {
return {
kind: "GreaterThan",
left,
right,
};
}
function GreaterThanOrEqual(left, right) {
return {
kind: "GreaterThanOrEqual",
left,
right,
};
}
function isSimpleValue(kind) {
return ([
"StringValue",
"FormatStringValue",
"ListValue",
"ListRange",
"Value",
"Addition",
"Subtraction",
"Multiplication",
"Division",
"Mod",
"Lambda",
"Equality",
"InEquality",
"LessThan",
"LessThanOrEqual",
"GreaterThan",
"GreaterThanOrEqual",
"And",
"Or",
"ListPrepend",
"ModuleReference",
"FunctionCall",
"LeftPipe",
"ObjectLiteral",
"Constructor",
].indexOf(kind) > -1);
}
function isLeftPipeableExpression(expression) {
return ([
"LeftPipe",
"ModuleReference",
"FunctionCall",
"Lambda",
"Value",
].indexOf(expression.kind) > -1);
}
function Function(name, returnType, args, letBody, body, doBody) {
return {
kind: "Function",
name,
returnType,
args,
letBody,
body,
doBody: doBody ? doBody : null,
};
}
function Const(name, type, letBody, value) {
return {
kind: "Const",
name,
type,
letBody,
value,
};
}
function ImportModule(name, alias, exposing, namespace) {
return {
kind: "ImportModule",
name,
alias,
exposing,
namespace,
};
}
function Import(modules) {
return {
kind: "Import",
modules,
};
}
function Export(names) {
return {
kind: "Export",
names,
};
}
function Comment(body) {
return {
kind: "Comment",
body,
};
}
function MultilineComment(body) {
return {
kind: "MultilineComment",
body,
};
}
function UnparsedBlock(kind, lineStart, lines) {
return {
kind,
lineStart,
lines,
};
}
function DoBlock(expressions) {
return {
kind: "DoBlock",
expressions,
};
}
function Module(name, body, errors) {
return {
kind: "Module",
name,
body,
errors,
};
}
function ContextModule(name, body, unparsedBody, errors) {
return {
kind: "ContextModule",
name,
body,
unparsedBody,
errors,
};
}
function contextModuleToModule(module) {
return Module(module.name, module.body, module.errors);
}