`react-vis` bindings

react-vis wants an array of {x: string|int|float, y: string|int|float} but I don't want a plethora of XtypeYtypeDataSeries for every X and Y in string, int and float.

I thought I could use functors for this but I can't. Specifically, I can't. I am sure this is possible, but I don't know how.

module BarSeriesDataFactory = {
  module type TheTypes = {
    type xType;
    type yType;
    [@bs.deriving jsConverter]
    type targetType = {
      x: xType,
      y: yType
    };
  };
  module TypedBarSeries = {
    [@bs.module "react-vis"]
    external reactClass : ReasonReact.reactClass = "VerticalBarSeries";
    let make = (~data, children) =>
      ReasonReact.wrapJsForReason(
        ~reactClass,
        ~props={"data": data},
        children
      );
  };
  module Make = (RC: TheTypes) => {
    let convert = (d: array(RC.targetType)) => {
      let jsArray = Array.map(r => RC.targetTypeToJs(r), d);
      /* d */
      <TypedBarSeries data=jsArray />;
    };
  };
};
  /* I had hoped I could then do: */
  module FirstSpec: BarSeriesDataFactory.TheTypes = {
    type xType = string;
    type yType = int;
    [@bs.deriving jsConverter]
    type targetType = {
      x: string,
      y: int
    };
  };
  let firstRow: FirstSpec.targetType = {x: "Q1", y: 10};
  let data: array(FirstSpec.targetType) = [|firstRow|]; */

The error that you get is:

Module build failed: Error: We've found a bug for you!
  /Users/coliny/Dev/wurble/src/ReactVis.re 110:42-45

  108 │ };
  109 │ 
  110 │ let firstRow: FirstSpec.targetType = {x: "Q1", y: 10};
  111 │ 
  112 │ let data: array(FirstSpec.targetType) = [|firstRow|];

  This has type:
    string
  But somewhere wanted:
    at <anonymous>e

results matching ""

    No results matching ""