Is there a way to limit the method so that it makes sense only if the two types are not equal?
trait Something[A, B] { // I can only be called if type A is the same as type B def ifEqual(implicit ev: A =:= B) // Now I cannot be called if type A is proven to be the same as type B def ifNotEqual(implicit ev: A ??? B) }
Yes. From shapeless ,
// Type inequalities trait =:!=[A, B] implicit def neq[A, B] : A =:!= B = new =:!=[A, B] {} implicit def neqAmbig1[A] : A =:!= A = ??? implicit def neqAmbig2[A] : A =:!= A = ???
Source: https://habr.com/ru/post/1546750/More articles:Spyon provider during configuration phase in angular.js application - javascriptОбъекты NSUserDefaults standardUserDefaults удаляются случайным образом - iosAdd multiple hover based styles - javascriptJavascript redirection according to browser language - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1546749/how-can-i-express-mapm-with-concat-using-lenses-to-concatenate-results-of-an-io-operation&usg=ALkJrhj7a_x4NW_l-qHYjAU-AupjLNe9iQОшибка в `/usr/bin/python ': double free или коррупция (out): 0x00007f7c3c017260 - pythonThe function R max ignores NA - maxGoogle Calendar API Value Notification Identification - phpConverting the white part of a log-spiral image to scatter a graph using MATLAB - mathhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1546755/what-are-the-g-flags-to-build-a-true-somhbundle-shared-library-on-mac-osx-not-a-dylib&usg=ALkJrhhMozMNqFvCOYz83eXhmbKKE294ywAll Articles