Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1912

Merge tuples types

$
0
0

at some point, you have to consume these results, so you have to know the dimension of your tuple and its inner types. What is the problem here? Is it about having tuples of dynamic size (which you can’t have), or is it that the combine function is too cumbersome?

If it’s the latter, you could combine them in a better manner:

let combine8 = (
  a: ReactFirehooks.Firestore.queryResult<'a>,
  b: ReactFirehooks.Firestore.queryResult<'b>,
  c: ReactFirehooks.Firestore.queryResult<'c>,
  d: ReactFirehooks.Firestore.queryResult<'d>,
  e: ReactFirehooks.Firestore.queryResult<'e>,
  f: ReactFirehooks.Firestore.queryResult<'f>,
  g: ReactFirehooks.Firestore.queryResult<'g>,
  h: ReactFirehooks.Firestore.queryResult<'h>,
) => {
  switch (combine7(a, b, c, d, e, f, g), h) {
  | (Loading, _)
  | (_, (_, true, _)) =>
    Loading
  | (Error(error), _)
  | (_, (_, _, Some(error))) =>
    Error(error)
  | (Data((qsA, qsB, qsC, qsD, qsE, qsF, qsG)), (Some(qsH), _, _)) =>
    Data((qsA, qsB, qsC, qsD, qsE, qsF, qsG, qsH))
  | _ => Unknown
  }
}

Viewing all articles
Browse latest Browse all 1912

Trending Articles