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

A few small questions

$
0
0

Why doesn’t type inference work in this scenario?

module M = {
  type t = {foo: string}
}

let a = []
let b: array<M.t> = a->Array.map(x => {foo: x})

It says the record field foo can’t be found. But I just gave it the context of M.t. This works:

let b = a->Array.map((x): M.t => {foo: x})

I understand why that works but it is way less intuitive to look at.


Viewing all articles
Browse latest Browse all 1813

Trending Articles