5

Problem:

I have a case class Passenger, that starts from point A and goes to point B.

A valid passenger means that point A doesn't equal to point B.

Passenger(
  a: Int,
  b: Int
)

Question:

How can I design Passenger class using refind library to reach the goal?

I think Passenger should take two or one refined type parameters, something like:

    Passenger[A, B Refined NotEqual[A]](...)

Example:

I expect that the following code doesn't compile:

Passenger(42, 42)

And this compiles correctly:

Passenger(1, 42)
mkUltra
  • 2,828
  • 1
  • 22
  • 47
  • Here is the link how it works in Haskell: https://stackoverflow.com/questions/53961764/can-i-define-parametric-data-type-where-parameters-are-not-equals-between-in-has – mkUltra May 29 '19 at 11:20
  • `a` and `b` are passed parameters which are only known at run-time, therefore I don't think a compile-time check is going to be possible. – jwvh May 29 '19 at 18:28

0 Answers0