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

Merge tuples types

$
0
0

you likely know at compile time the types of the results you’re going to get, so depending on how you can to consume the results, you have multiple choices.

  1. create a record:
type okResults = {
  a?: A.res,
  b?: B.res,
  c?: C.res,
}
  1. or you can use an array of variants:
type okResult =
  | A(A.res)
  | B(B.res)
  | C(C.res)

type okResults = array<okResult>

You need to have some kind of knowledge of the shape of your result on compile time, otherwise the compiler can’t help you!


Viewing all articles
Browse latest Browse all 1941

Trending Articles