[Haskell-cafe] Newbie question on Haskell type
robert dockins
robdockins at fastmail.fm
Thu Oct 13 17:01:37 EDT 2005
In GHC you can do this:
> import Data.Typeable
> isString :: (Typeable a) => a -> Bool
> isString x = typeOf x == typeOf (undefined::String)
Why do you want this? It's not the kind of operation one does very
often in Haskell.
Huong Nguyen wrote:
> Hi all,
>
> I want to write a small functionto test whether an input is a String or
> not. For example,
>
> isString::(Show a) =>a ->Bool
> This function will return True if the input is a string and return False
> if not
>
> Any of you have idea about that? Thanks in advance
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list