show either result or bindings in viewer
This commit is contained in:
parent
4a3c982c57
commit
59ed741f33
|
@ -1,5 +1,12 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { SqValue, environment, defaultEnvironment } from "@quri/squiggle-lang";
|
import {
|
||||||
|
SqValue,
|
||||||
|
environment,
|
||||||
|
defaultEnvironment,
|
||||||
|
resultMap,
|
||||||
|
SqValueLocation,
|
||||||
|
SqValueTag,
|
||||||
|
} from "@quri/squiggle-lang";
|
||||||
import { useSquiggle } from "../lib/hooks";
|
import { useSquiggle } from "../lib/hooks";
|
||||||
import { SquiggleViewer } from "./SquiggleViewer";
|
import { SquiggleViewer } from "./SquiggleViewer";
|
||||||
|
|
||||||
|
@ -97,28 +104,20 @@ export const SquiggleChart: React.FC<SquiggleChartProps> = React.memo(
|
||||||
count: diagramCount,
|
count: diagramCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resultToRender = resultMap(result, (value) =>
|
||||||
|
value.tag === SqValueTag.Void ? bindings.asValue() : value
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<SquiggleViewer
|
||||||
<SquiggleViewer
|
result={resultToRender}
|
||||||
result={result}
|
width={width}
|
||||||
width={width}
|
height={height}
|
||||||
height={height}
|
distributionPlotSettings={distributionPlotSettings}
|
||||||
distributionPlotSettings={distributionPlotSettings}
|
chartSettings={chartSettings}
|
||||||
chartSettings={chartSettings}
|
environment={environment ?? defaultEnvironment}
|
||||||
environment={environment ?? defaultEnvironment}
|
enableLocalSettings={enableLocalSettings}
|
||||||
enableLocalSettings={enableLocalSettings}
|
/>
|
||||||
/>
|
|
||||||
<hr className="my-4" />
|
|
||||||
<SquiggleViewer
|
|
||||||
result={{ tag: "Ok", value: bindings.asValue() }}
|
|
||||||
width={width}
|
|
||||||
height={height}
|
|
||||||
distributionPlotSettings={distributionPlotSettings}
|
|
||||||
chartSettings={chartSettings}
|
|
||||||
environment={environment ?? defaultEnvironment}
|
|
||||||
enableLocalSettings={enableLocalSettings}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,4 +18,4 @@ export type MergedItemSettings = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const locationAsString = (location: SqValueLocation) =>
|
export const locationAsString = (location: SqValueLocation) =>
|
||||||
location.path.root + "/" + location.path.items.join(".");
|
location.path.items.join(".");
|
||||||
|
|
|
@ -20,4 +20,11 @@ export class SqModule {
|
||||||
this.location
|
this.location
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get(k: string) {
|
||||||
|
const v = RSModuleValue.get(this._value, k);
|
||||||
|
return v === undefined || v === null
|
||||||
|
? undefined
|
||||||
|
: wrapValue(v, this.location.extend(k));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,3 +11,6 @@ let toString = (v: squiggleValue_Module): string =>
|
||||||
|
|
||||||
@genType
|
@genType
|
||||||
let toSquiggleValue = (v: squiggleValue_Module): squiggleValue => IEvBindings(v)
|
let toSquiggleValue = (v: squiggleValue_Module): squiggleValue => IEvBindings(v)
|
||||||
|
|
||||||
|
@genType
|
||||||
|
let get = ReducerInterface_InternalExpressionValue.nameSpaceGet
|
||||||
|
|
|
@ -239,3 +239,9 @@ let nameSpaceToKeyValuePairs = (nameSpace: nameSpace): array<(string, t)> => {
|
||||||
let NameSpace(container) = nameSpace
|
let NameSpace(container) = nameSpace
|
||||||
container->Belt.Map.String.toArray
|
container->Belt.Map.String.toArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nameSpaceGet = (nameSpace: nameSpace, key: string): option<t> => {
|
||||||
|
let NameSpace(container) = nameSpace
|
||||||
|
container->Belt.Map.String.get(key)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user