[Haskell-cafe] Newbie question on Haskell type

Neil Mitchell ndmitchell at gmail.com
Thu Oct 13 16:20:45 EDT 2005

> isString::(Show a) =>a ->Bool
> This function will return True if the input is a string and return False if
> not
This is not particularly nicely - you certainly can't write it as
simple as the 'isString' function, and it will probably require type
classes etc, quite possibly with haskell extensions. Since haskell is
a statically typed langauge the idea is that you know if something is
a string before you run the program, not only at runtime.

Why is it you want this? Perhaps what you are hoping to accomplish
could be done some other way, without requiring this isString

Of course, if you want a slightly hacky version:

isString x = not (null a) && head a == '\"' && last a == '\"'
   where a = show x

is probably good enough :)



More information about the Haskell-Cafe mailing list