Comparing version 0.0.3-18 to 0.0.3-19
{ | ||
"name": "derw", | ||
"version": "0.0.3-18", | ||
"version": "0.0.3-19", | ||
"description": "An Elm-inspired language that transpiles to TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -274,4 +274,10 @@ import { | ||
case "FixedType": { | ||
if (type_.name === "List") { | ||
return generateType(type_); | ||
if ( | ||
type_.args.length > 0 && | ||
type_.args[0].kind === "FixedType" && | ||
type_.args[0].args.length > 0 | ||
) { | ||
return `${type_.name} (${type_.args | ||
.map(generateTopLevelType) | ||
.join(" ")})`; | ||
} | ||
@@ -577,5 +583,5 @@ | ||
case "FunctionArg": | ||
return generateType(arg.type); | ||
return generateTopLevelType(arg.type); | ||
case "AnonFunctionArg": | ||
return generateType(arg.type); | ||
return generateTopLevelType(arg.type); | ||
} | ||
@@ -670,6 +676,18 @@ }) | ||
export function generateDerw(module: Module): string { | ||
return module.body | ||
.map(generateBlock) | ||
.filter((line) => line.length > 0) | ||
.join("\n\n"); | ||
const importBlocks = module.body.filter((block) => block.kind === "Import"); | ||
const nonImportBlocks = module.body.filter( | ||
(block) => block.kind !== "Import" | ||
); | ||
return [ | ||
...importBlocks | ||
.map(generateBlock) | ||
.filter((line) => line.length > 0) | ||
.join("\n"), | ||
importBlocks.length > 0 ? "\n\n" : "", | ||
...nonImportBlocks | ||
.map(generateBlock) | ||
.filter((line) => line.length > 0) | ||
.join("\n\n"), | ||
].join(""); | ||
} |
@@ -264,4 +264,10 @@ import { | ||
case "FixedType": { | ||
if (type_.name === "List") { | ||
return generateType(type_); | ||
if ( | ||
type_.args.length > 0 && | ||
type_.args[0].kind === "FixedType" && | ||
type_.args[0].args.length > 0 | ||
) { | ||
return `${type_.name} (${type_.args | ||
.map(generateTopLevelType) | ||
.join(" ")})`; | ||
} | ||
@@ -571,5 +577,5 @@ | ||
case "FunctionArg": | ||
return generateType(arg.type); | ||
return generateTopLevelType(arg.type); | ||
case "AnonFunctionArg": | ||
return generateType(arg.type); | ||
return generateTopLevelType(arg.type); | ||
} | ||
@@ -576,0 +582,0 @@ }) |
Sorry, the diff of this file is too big to display
791729
22738
114