Simon Peyton Jones
simonpj at microsoft.com
Wed Aug 2 08:19:26 UTC 2017
Based on memory rather that investigation:
- yes it works on any data type
- The reason that the primop dataToTag# is dangerous is that it does
not evaluate its argument; it relies on the wrapper getTag to do
so. Caveat emptor! It would be good to document this.
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of
| David Feuer
| Sent: 02 August 2017 03:04
| To: ghc-devs at haskell.org
| Subject: dataToTag# documentation
| 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
| 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#?
| ghc-devs mailing list
| ghc-devs at haskell.org
More information about the ghc-devs