question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enum members and union types

See original GitHub issue
enum ParseResult {
  case Trees(xs: List[Int])
  case Errors(xs: List[String])
  case Incomplete
  case Exit
}

import ParseResult._

type Fine     = Trees | Errors
type NotFine0 = Trees | Incomplete
type NotFine1 = Trees | Errors | Incomplete
type NotFine2 = Trees | Errors | Exit

I’m assuming this is due to Incomplete and Exit getting desugared into:

final case val Exit: Test.ParseResult = Test.ParseResult.$new(3, "Exit")

ping @odersky

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
felixmuldercommented, Jun 9, 2017

@japgolly - there was some breakage a while back, where at the time, we decided that fixing the breakage was more important than allowing singleton types in unions.

I’m hoping that we can get back to enabling this again, but so far other things have taken priority. If you’re interested in helping out on this, we’re more than happy to help you get started 😃

1reaction
japgollycommented, Jun 8, 2017

singleton types are not allowed in union types currently

oh god… please tell me that’s going to change at some point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Union Types vs. Enums in TypeScript
Conceptually, enums can be a subset of union types with numeric or string values. Numeric enums are less safe. If you call updateStatus(20)...
Read more >
TypeScript | Union Types vs Enums
Learn the difference between using union types and enums in TypeScript with simple examples, as well as understanding when to use one or...
Read more >
Should You Use Enums or Union Types in Typescript?
There's only one way to use union types, while with enums you can use ButtonStatus. · If code uniformity matters to you, it's...
Read more >
Handbook - Enums - TypeScript
Union enums and enum member types. There is a special subset of constant enum members that aren't calculated: literal enum members. A literal...
Read more >
Typescript has unions, so are enums redundant?
Enums can be seen conceptually as a subset of union types, dedicated to int and/or string ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found