Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support undecidable generics #30

Open
KacperFKorban opened this issue Mar 20, 2024 · 1 comment
Open

Support undecidable generics #30

KacperFKorban opened this issue Mar 20, 2024 · 1 comment

Comments

@KacperFKorban
Copy link
Owner

KacperFKorban commented Mar 20, 2024

It should be possible to use undecidable generics types in function definitions.

e.g.

sealed trait WeirdGADT[+A]
case class IntValue(value: Int) extends WeirdGADT[Int]
case class SomeValue[+A](value: A) extends WeirdGADT[A]
case class SomeOtherValue[+A, +B](value: A, value2: B) extends WeirdGADT[A]

// This fails on unknown type params
def printsWeirdGADT(g: WeirdGADT[String]): String = g match
  case SomeValue(value) => s"SomeValue($value)"
  case SomeOtherValue(value, value2) => s"SomeOtherValue($value, $value2)"

This fails, because SomeOtherValue cannot be fully constructed based on parent's type params.

Either some default will have to be used or a new type of form element introduced - one that lets the user pick any supported type.

It should also be possible to use generic functions with GUInep.

e.g.

def showMaybe[A](maybe: Option[A]): String = maybe match
  case None => "None"
  case Some(v) => s"Some(${v.toString})"

This might require similar mechanisms. Plus the support for this kind of input.

@KacperFKorban
Copy link
Owner Author

This is an extension of #28

@KacperFKorban KacperFKorban changed the title Support undecidable generics Support undecidable generics and generic functions Mar 20, 2024
@KacperFKorban KacperFKorban modified the milestone: 0.1.0 Apr 7, 2024
@KacperFKorban KacperFKorban changed the title Support undecidable generics and generic functions Support undecidable generics Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant