mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-18 19:10:18 +00:00
Load up
This commit is contained in:
parent
87bb6c8437
commit
7d3e7ffdfb
4 changed files with 21 additions and 570 deletions
|
@ -1,14 +1,9 @@
|
|||
import React from "react";
|
||||
import FileInput, { LoadedEvents } from "./components/FileInput";
|
||||
import Ui from "./components/Ui";
|
||||
import data from "./checkmate.json";
|
||||
import { AllEvents } from "./schema";
|
||||
|
||||
export default function App() {
|
||||
const [events, setEvents] = React.useState<LoadedEvents | null>({
|
||||
kind: "ok",
|
||||
events: data as AllEvents,
|
||||
});
|
||||
const [events, setEvents] = React.useState<LoadedEvents | null>(null);
|
||||
|
||||
return (
|
||||
<div className="w-screen h-screen p-2 bg-gray-100">
|
||||
|
|
|
@ -1,545 +0,0 @@
|
|||
[
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1540,
|
||||
"right": 71,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 71,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Function",
|
||||
"arguments": [1543, 1544],
|
||||
"lambda_type": 1542,
|
||||
"ret": 1541
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1540, "to": 71 },
|
||||
{ "type": "VariableUnified", "from": 71, "to": 71 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 71,
|
||||
"right": 1546,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1543,
|
||||
"right": 67,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 67,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [1545],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1545,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1543, "to": 67 },
|
||||
{ "type": "VariableUnified", "from": 67, "to": 67 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1544,
|
||||
"right": 69,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 69,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [1545],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1545,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1544, "to": 69 },
|
||||
{ "type": "VariableUnified", "from": 69, "to": 69 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1541,
|
||||
"right": 73,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 73,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [1545],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1545,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1541, "to": 73 },
|
||||
{ "type": "VariableUnified", "from": 73, "to": 73 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1542,
|
||||
"right": 72,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 72,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "LambdaSet",
|
||||
"solved": [{ "function": "`Num.add`", "environment": [] }],
|
||||
"unspecialized": [],
|
||||
"recursion_var": null,
|
||||
"ambient_function": 1540
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1542, "to": 72 },
|
||||
{ "type": "VariableUnified", "from": 72, "to": 72 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1546,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Function",
|
||||
"arguments": [67, 69],
|
||||
"lambda_type": 1542,
|
||||
"ret": 73
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 71, "to": 1546 },
|
||||
{ "type": "VariableUnified", "from": 1546, "to": 1546 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 66,
|
||||
"right": 1547,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1547,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "RangedNumber",
|
||||
"range": {
|
||||
"kind": { "type": "AnyNum" },
|
||||
"signed": true,
|
||||
"min_width": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 66, "to": 1547 },
|
||||
{ "type": "VariableUnified", "from": 1547, "to": 1547 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1548,
|
||||
"right": 67,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 66,
|
||||
"right": 1545,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1545,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "RangedNumber",
|
||||
"range": {
|
||||
"kind": { "type": "AnyNum" },
|
||||
"signed": true,
|
||||
"min_width": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1547, "to": 1545 },
|
||||
{ "type": "VariableUnified", "from": 1545, "to": 1545 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 67,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [66],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 66,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1548, "to": 67 },
|
||||
{ "type": "VariableUnified", "from": 67, "to": 67 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 68,
|
||||
"right": 1549,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1549,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "RangedNumber",
|
||||
"range": {
|
||||
"kind": { "type": "AnyNum" },
|
||||
"signed": true,
|
||||
"min_width": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 68, "to": 1549 },
|
||||
{ "type": "VariableUnified", "from": 1549, "to": 1549 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1550,
|
||||
"right": 69,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 68,
|
||||
"right": 1545,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1545,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "RangedNumber",
|
||||
"range": {
|
||||
"kind": { "type": "AnyNum" },
|
||||
"signed": true,
|
||||
"min_width": 8
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1549, "to": 1545 },
|
||||
{ "type": "VariableUnified", "from": 1545, "to": 1545 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 69,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [68],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 68,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1550, "to": 69 },
|
||||
{ "type": "VariableUnified", "from": 69, "to": 69 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 73,
|
||||
"right": 1551,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 73,
|
||||
"right": 1552,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1545,
|
||||
"right": 1553,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1556,
|
||||
"right": 1554,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1554,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Unsigned8`",
|
||||
"variables": {
|
||||
"type_variables": [],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1555,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1556, "to": 1554 },
|
||||
{ "type": "VariableUnified", "from": 1554, "to": 1554 }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1545,
|
||||
"right": 1553,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1553,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Integer`",
|
||||
"variables": {
|
||||
"type_variables": [1556],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1556,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1545, "to": 1553 },
|
||||
{ "type": "VariableUnified", "from": 1553, "to": 1553 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 1552,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.Num`",
|
||||
"variables": {
|
||||
"type_variables": [1545],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1545,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 73, "to": 1552 },
|
||||
{ "type": "VariableUnified", "from": 1552, "to": 1552 }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1551,
|
||||
"right": 75,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 75,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.U8`",
|
||||
"variables": {
|
||||
"type_variables": [],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1552,
|
||||
"kind": { "type": "Structural" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1551, "to": 75 },
|
||||
{ "type": "VariableUnified", "from": 75, "to": 75 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 80,
|
||||
"right": 75,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 75,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Num.U8`",
|
||||
"variables": {
|
||||
"type_variables": [],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1552,
|
||||
"kind": { "type": "Structural" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 80, "to": 75 },
|
||||
{ "type": "VariableUnified", "from": 75, "to": 75 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1557,
|
||||
"right": 79,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 79,
|
||||
"rank": 1,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Bool.Bool`",
|
||||
"variables": {
|
||||
"type_variables": [],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1558,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1557, "to": 79 },
|
||||
{ "type": "VariableUnified", "from": 79, "to": 79 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 79,
|
||||
"right": 5,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 1558,
|
||||
"right": 4,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "Unification",
|
||||
"left": 84,
|
||||
"right": 3,
|
||||
"mode": { "type": "Eq" },
|
||||
"success": true,
|
||||
"subevents": [
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 3,
|
||||
"rank": 0,
|
||||
"content": { "type": "EmptyTagUnion" }
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 84, "to": 3 },
|
||||
{ "type": "VariableUnified", "from": 3, "to": 3 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 4,
|
||||
"rank": 0,
|
||||
"content": {
|
||||
"type": "TagUnion",
|
||||
"tags": { "False": [], "True": [] },
|
||||
"extension": { "type": "Any", "variable": 84 }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 1558, "to": 4 },
|
||||
{ "type": "VariableUnified", "from": 4, "to": 4 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "VariableSetDescriptor",
|
||||
"variable": 5,
|
||||
"rank": 0,
|
||||
"content": {
|
||||
"type": "Alias",
|
||||
"name": "`Bool.Bool`",
|
||||
"variables": {
|
||||
"type_variables": [],
|
||||
"lambda_set_variables": [],
|
||||
"infer_ext_in_output_position_variables": []
|
||||
},
|
||||
"real_variable": 1558,
|
||||
"kind": { "type": "Opaque" }
|
||||
}
|
||||
},
|
||||
{ "type": "VariableUnified", "from": 79, "to": 5 },
|
||||
{ "type": "VariableUnified", "from": 5, "to": 5 }
|
||||
]
|
||||
}
|
||||
]
|
|
@ -25,9 +25,9 @@ export default function FileInput({ setResult }: FileInputProps) {
|
|||
return;
|
||||
}
|
||||
const file = files[0];
|
||||
const buf = await file.arrayBuffer();
|
||||
const buf = await file.text();
|
||||
try {
|
||||
const events: AllEvents = JSON.parse(new TextDecoder().decode(buf));
|
||||
const events: AllEvents = JSON.parse(buf);
|
||||
setResult({ kind: "ok", events });
|
||||
} catch (e) {
|
||||
setResult({ kind: "err", error: "Invalid checkmate file." });
|
||||
|
@ -36,18 +36,13 @@ export default function FileInput({ setResult }: FileInputProps) {
|
|||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<label htmlFor="small-file-input" className="sr-only">
|
||||
Choose file
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
name="small-file-input"
|
||||
id="small-file-input"
|
||||
onChange={(e) => setFile(e)}
|
||||
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
|
||||
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4"
|
||||
></input>
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
name="small-file-input"
|
||||
id="small-file-input"
|
||||
onChange={(e) => setFile(e)}
|
||||
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
|
||||
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4 cursor-pointer"
|
||||
></input>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ export default function Ui({ events }: UiProps): JSX.Element {
|
|||
const engine = new Engine(events);
|
||||
|
||||
return (
|
||||
<div className="font-mono mt-4">
|
||||
<div className="font-mono mt-4 text-lg">
|
||||
<EventList engine={engine} root events={events}></EventList>
|
||||
</div>
|
||||
);
|
||||
|
@ -31,7 +31,7 @@ const UNFOCUSED = "opacity-40";
|
|||
|
||||
function EventList({ engine, events, root }: EventListProps): JSX.Element {
|
||||
return (
|
||||
<ul className={clsx(MT, root ? "ml-2" : "ml-[1.5em]", "relative")}>
|
||||
<ul className={clsx(MT, root ? "ml-2" : "ml-[1.5em]")}>
|
||||
{events.map((event, i) => (
|
||||
<li key={i} className={MT}>
|
||||
<OneEvent engine={engine} event={event} />
|
||||
|
@ -60,7 +60,7 @@ function OneEvent({ event, engine }: OneEventProps): JSX.Element {
|
|||
const DROPDOWN_CLOSED = "▶";
|
||||
const DROPDOWN_OPEN = "▼";
|
||||
|
||||
const UN_UNKNOWN = "❔";
|
||||
const UN_UNKNOWN = "💭";
|
||||
const UN_SUCCESS = "✅";
|
||||
const UN_FAILURE = "❌";
|
||||
|
||||
|
@ -121,7 +121,13 @@ function Unification({ engine, event }: UnificationProps): JSX.Element {
|
|||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className={clsx(
|
||||
"relative",
|
||||
"before:content-[''] before:border-l before:border-slate-400",
|
||||
"before:absolute before:w-0 before:h-[calc(100%-2rem)] before:top-[1.5rem] before:left-[0.3rem]"
|
||||
)}
|
||||
>
|
||||
<div>{headlineBefore}</div>
|
||||
<EventList engine={engine} events={subevents} />
|
||||
{headlineAfter}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue