- the goal of this project is to be able to use the the lab.json and theme.json files generated by compositor.io's lab project in a reasonml project.
yarn
thenyarn start
.
- Decoding with bs-json returns a reason record type. Right?
- implemented in src/DemoMap.re
- This seems to work when operating straight of the raw json in Demo.x. If you decode to a record it works with component.name syntax as seen in
src/Lab.components
getComponentMap ().
let getComponentMap = myList =>
List.fold_left(
(map, component) => StringMap.add(component##name, component, map),
StringMap.empty,
myList,
);
- But then in
src/LabTyped.re
, it will throw error oncomponent.name
syntax and acceptcomponent##name
syntax but then throws this type error.:
/Users/prisc_000/code/REASON/EXPLORINGReML/labdemo-re/src/LabTyped.re 124:36-41
122 │ );
123 │
124 │ let componentMap = getComponentMap(myList);
This has type:
list(Types.component)
But somewhere wanted:
list(Js.t(({.. name: StringMap.key} as 'a)))
The incompatible parts:
Types.component
vs
Js.t('a) at <anonymous>
- LabTyped Error #2
104 │ };
105 │
106 │ let lab = labJson |> Decoder.decodeLab;
107 │
108 │ let components: list(Types.component) = lab.components;
This has type:
Js.Json.t => Types.lab
But somewhere wanted:
Js.t(({.. } as 'a)) => 'b
The incompatible parts:
Js.Json.t (defined as Js.Json.t)
vs
Js.t('a)
ninja: build stopped: subcommand failed.
- So, something about
list(Types.component)
in LabTyped.re, (which I am assuming is a record type because we decoded it),that doesnt work with StringMap's String module. The difference between LabTyped.re and Lab.re is that in Lab.re I jump right to components by defining withcomponents = lab##components;
while in LabTyped.re I decode all of the lab.json then pull components off of the already decoded lab withcomponents = lab.components
- I can't quite get my head around this yet. Anyone? Anyone? Anyone?
- It works but there must be a better way. See
src/labdemo/DemoVariants.re