Unlifted data types

Dan Doel dan.doel at gmail.com
Fri Sep 4 21:48:49 UTC 2015


On Fri, Sep 4, 2015 at 5:23 PM, Edward Z. Yang <ezyang at mit.edu> wrote:
> But this kind of special handling is a bit bothersome. Consider:
>
>     data SPair a b = SPair (!a, !b)
>
> The constructor has what type?  Probably
>
>     SPair :: (Force a, Force b) -> SPair a
>
> and not:
>
>     SPair :: (a, b) -> SPair a

I don't really understand what this example is showing. I don't think
SPair is a legal
declaration in any scenario.

- In current Haskell it's illegal; you can only put ! directly on fields
- If !a :: Unlifted, then (,) (!a) is a kind error (same with Force a)

> I don't think it interacts any differently than with unpacked/unboxed
> products today.

I meant like:

If T :: Unlifted, then am I allowed to do:

    data U = MkU {-# UNPACK #-} T ...

and what are its semantics? If T is a sum, presumably it's related to
the unpacked
sums proposal from a couple days ago. Does stuff from this proposal
make that proposal
simpler? Should they reference things in one another?

Will there be optimizations that turn:

    data E a b :: Unlifted where
      L :: a -> E a b
      R :: b -> E a b

into |# a , b #| (or whatever the agreed upon syntax is)? Presumably yes.

-- Dan


More information about the ghc-devs mailing list