syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Express list literal variants

Open rickyvetter opened this issue 3 years ago • 3 comments

In OCaml and Reason this code is valid, is there a way to express in ReScript? Any intent to support?

type t('a) =
| []
| ::('a, t('a))

rickyvetter avatar Apr 28 '21 17:04 rickyvetter

There's currently no way to express this in ReScript. Is this urgent? What's your use case?

IwanKaramazow avatar Apr 28 '21 18:04 IwanKaramazow

Not urgent - we have some code that uses this to create a heterogeneous list but can keep that in .ml for now.

rickyvetter avatar Apr 28 '21 19:04 rickyvetter

Something like:

type rec t<'a> =
| Empty
| Cons('a, t<'a>)

Conaclos avatar May 07 '21 17:05 Conaclos

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 23:05 stale[bot]