C#:
static int F(object x)
{
return x is string ? 1 : 2;
}
Haskell?
The tricky bit seems to me that Haskell does not have a root type object.
Edited: I do not care about converting to string. I want to know how to typecast (for example to see if an object is a Customer or an Order.