dataToTag# documentation

David Feuer david at well-typed.com
Wed Aug 2 02:03:51 UTC 2017


dataToTag# is documented as getting the tag number of an enumeration,
which is perfectly reasonable because it's designed to support deriving Enum.
But it *appears* to work also for non-enumeration datatypes:

dataToTag# Nothing = 0#
dataToTag# (Just 3) = 1#

Does this actually always work? If so, should that be documented, or is there
a realistic possibility that its behavior will change in the future?

Additionally: the documentation for dataToTag# urges readers to use
GHC.Base.getTag instead. But dataToTag# is exported from the "public"
GHC.Exts, whereas getTag is not. Should we add getTag to GHC.Exts,
or change the documentation for dataToTag#?

David


More information about the ghc-devs mailing list