How does SQL Server decide format for implicit datetime conversion?

This can depend on a variety of factors – the operating system’s regional settings, the current user’s language and dateformat settings. By default, Windows uses US English, and the user’s settings are US English and MDY. But here are some examples to show how this can change. User is using BRITISH language settings: — works: … Read more

Why is this implicit ambiguity behaviour happening?

Scala specification says: If there are several eligible arguments which match the implicit parameter’s type, a most specific one will be chosen using the rules of static overloading resolution. https://www.scala-lang.org/files/archive/spec/2.13/07-implicits.html#implicit-parameters The relative weight of an alternative A over an alternative B is a number from 0 to 2, defined as the sum of 1 if … Read more

Why does the compiler choose bool over string for implicit typecast of L””?

First, the cause of this issue: C++ Standard [over.ics.rank]/2.11 defines an order for conversion sequences. It says that a user defined conversion sequence is worse than a standard conversion sequence. What happens in your case is that the string literal undergoes a boolean-conversion (defined at 4.12. This is a standard conversion). It does not use … Read more

Using context bounds “negatively” to ensure type class instance is absent from scope

I eventually solved this using an ambiguity-based solution that doesn’t require prioritizing using inheritance. Here is my attempt at generalizing this. We use the type Not[A] to construct negative type classes: import scala.language.higherKinds trait Not[A] trait Monoid[_] // or import scalaz._, Scalaz._ type NotMonoid[A] = Not[Monoid[A]] trait Functor[_[_]] // or import scalaz._, Scalaz._ type NotFunctor[M[_]] … Read more

Android, How to read QR code in my application?

try { Intent intent = new Intent(“com.google.zxing.client.android.SCAN”); intent.putExtra(“SCAN_MODE”, “QR_CODE_MODE”); // “PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { Uri marketUri = Uri.parse(“market://details?id=com.google.zxing.client.android”); Intent marketIntent = new Intent(Intent.ACTION_VIEW,marketUri); startActivity(marketIntent); } and in onActivityResult(): @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0) { if (resultCode … Read more

In scala 2 or 3, is it possible to debug implicit resolution process in runtime?

You can debug implicits at compile time: switch on compiler flag -Xlog-implicits try to resolve implicits manually (maybe specifying type parameters as well) and see compile errors implicitly[…](…manually…) use scala.reflect println(reify { implicitly[…] }.tree) (or switch on compiler flag -Xprint:typer) in order to see how implicits are resolved use IDE functionality to show implicits using … Read more

Scala: Implicit parameter resolution precedence

I wrote my own answer in the form of a blog post revisiting implicits without import tax. Update: Furthermore, the comments from Martin Odersky in the above post revealed that the Scala 2.9.1’s behavior of LocalIntFoo winning over ImportedIntFoo is in fact a bug. See implicit parameter precedence again. 1) implicits visible to current invocation … Read more