Unpacking single-field, single-strict-constructor GADTs and existentials

David Feuer david.feuer at gmail.com
Thu May 19 14:30:54 UTC 2016

Data.IntMap could be cleaned up some if single-field, single strict
constructor GADTs/existentials could be unpacked even when wrapping a sum
type. We could then have

data Status = E | NE
data IntMap' (s :: Status) a where
  Bin :: ... -> ... -> !(IntMap' NE a) -> !(IntMap' NE a) -> IntMap' NE a
  Tip :: ... -> a -> IntMap' NE a
  Nil :: IntMap' E a
data IntMap a =
  forall s . IM {-# UNPACK #-} !(IntMap' s a)

The representation would be the same as that of a newtype, but the pattern
matching semantics would be strict. In the GADT case, this would
essentially allow any fixed concrete datatype to serve directly as a
witness for an arbitrary set of type equalities demanded on construction.

Is there any hope something like this could happen?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160519/62f90ce7/attachment.html>

More information about the ghc-devs mailing list