[Haskell-beginners] discover data constructor without pattern matching?
Philippe Sismondi
psismondi at arqux.com
Fri Dec 2 02:32:56 CET 2011
On 2011-12-01, at 5:47 PM, Ozgur Akgun wrote:
> Hi,
>
> On 1 December 2011 22:38, Philippe Sismondi <psismondi at arqux.com> wrote:
> Is it possible to discover the data constructor used to make a value without doing pattern matching?
>
> Yes, it is.
>
> constrName :: Data a => a -> String
> constrName = show . toConstr
>
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Data.html#v:toConstr
>
> (You can derive Data for your data type using the language extension DeriveDataTypeable)
>
> Hope this helps,
Wow, it sure does. Thanks a million.
> Ozgur
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111201/acb7c210/attachment.htm>
More information about the Beginners
mailing list