-
Notifications
You must be signed in to change notification settings - Fork 63
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
Unify polymorphic output handling #805
Comments
I believe that client goals should include ease of use |
Alternatively, as suggested by @drmarjanovic we might be able to utilize |
I would not recommend using a response ADT, because then you need to pattern match against the return value and have to deal with cases that you know can't happen due to the parameters that were passed to the function. IOW it'd force you to write dead code. There are two ways in Scala to model a function that returns different types depending on its input parameters. The first is GADTs: sealed trait Want[A]
object WantString extends Want[String]
object WantInt extends Want[Int]
def foo[A](want: Want[A]): A =
want match {
case WantString => "spam and eggs"
case WantInt => 42
}
val x: Int = foo(WantInt) The second is abstract type members: sealed trait Want {
type Ret
def value: Ret
}
object WantInt extends Want {
type Ret = Int
def value: Int = 42
}
object WantString extends Want {
type Ret = String
def value: String = "spam and eggs"
}
def foo(want: Want): want.Ret =
want.value
val x: Int = foo(WantInt) |
@mberndt123 Correct. I mentioned a few that came to my mind, the ticket is fully open for experimentation. |
Yeah sure, so I wanted to add what came to my mind 😉 |
Some Redis commands return a different type of output depending on their input. We need to collect them and uniformly represent them. There are a few approaches that come to mind:
set
andsetGet
; this approach maximizes usability on the price of slight divergence from Redis naming and proliferation of exposed functions.The text was updated successfully, but these errors were encountered: