diff --git a/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx b/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx index 1417fb28..9a3e266e 100644 --- a/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx +++ b/packages/components/src/components/SquiggleViewer/ExpressionViewer.tsx @@ -59,6 +59,13 @@ export const ExpressionViewer: React.FC = ({ expression, width, }) => { + if (typeof expression !== "object") { + return ( + + {() => `Unknown expression: ${expression}`} + + ); + } switch (expression.tag) { case "number": return ( @@ -281,10 +288,16 @@ export const ExpressionViewer: React.FC = ({ ); default: { return ( -
- No display for type: {" "} - {expression.tag} -
+ + {() => ( +
+ No display for type: {" "} + + {expression.tag} + +
+ )} +
); } } diff --git a/packages/squiggle-lang/src/js/rescript_interop.ts b/packages/squiggle-lang/src/js/rescript_interop.ts index 80548a7f..3dca8165 100644 --- a/packages/squiggle-lang/src/js/rescript_interop.ts +++ b/packages/squiggle-lang/src/js/rescript_interop.ts @@ -18,6 +18,7 @@ import { tagged, tag } from "./types"; // Raw rescript types. export type rescriptExport = + | 0 // EvVoid | { TAG: 0; // EvArray _0: rescriptExport[]; @@ -140,6 +141,10 @@ export function convertRawToTypescript( result: rescriptExport, environment: environment ): squiggleExpression { + if (typeof result === "number") { + // EvVoid + return tag("void", ""); + } switch (result.TAG) { case 0: // EvArray return tag(