[ghc-steering-committee] Unlifted data types

Eric Seidel eric at seidel.io
Wed Aug 18 02:57:07 UTC 2021


I think the distance between the `type IntU` and `data IntU` is the crux of the issue. If we were forced to keep the signature and declaration together, i.e.

```
type IntU :: Bool -> Wombat
data IntU a b = IntU Int
```

I wouldn't be bothered by the distance from the definition of `Wombat`.

If I'm reading this code, and I already know what Wombat is, there's no problem. If I *don't* know what Wombat is, then I need to look up its definition anyway to make sense of IntU.

I've never been particularly fond of Haskell's tolerance for separating signatures and definitions. It has some practical uses -- notably in combination with -XCPP it makes it easy to ensure signatures are consistent across CPP branches -- but in general I think distance between signature and definition is a smell.

On Wed, Aug 11, 2021, at 03:48, Simon Peyton Jones via ghc-steering-committee wrote:
>  
> I have just posted 
> <https://github.com/ghc-proposals/ghc-proposals/pull/265#issuecomment-896626642> this, about unlifted data types.  Yikes!  
> Simon
>  
> *In accepted proposal #265 on Unlifted Datatypes 
> <https://github.com/ghc-proposals/ghc-proposals/pull/265>*
> I have just realised that in this accepted, and implemented proposal we 
> have done something entirely new. Consider this (from 
> https://gitlab.haskell.org/ghc/ghc/-/issues/20204)
> 
> `type IntU ::  Bool -> Wombat` ` ` `...LOTS OF CODE...` ` ` `data IntU 
> a b = IntU Int` ` ` `...MORE CODE...` ` ` `type Wombat =Type -> TYPE 
> UnliftedRep` 
> The kind signature for `IntU` *completely changes the semantics of the 
> *`*data IntU*`* declaration*, and yet can be separate from it. That is 
> new: generally, signatures can restrict the applicability of something, 
> but *don't change its semantics*. (Yes, with overlapping instances, 
> certainly incoherent instances, you could change semantics, but the 
> general principal holds.)
> 
> Even if it is adjacent, the fact that it's unlifted is quite subtle... 
> you have to look to the right of the arrows, and then through the 
> distant (and perhaps imported) type synonym `Wombat`.
> 
> I'm not very happy with a distant kind signature having such a profound 
> effect on the semantics of the data type. Indeed in my comment above 
> <https://github.com/ghc-proposals/ghc-proposals/pull/265#issuecomment-525705557> I suggested a keyword
> 
> `data unlifted IntU a b = IntU Int` 
> to signal that it's an *unlifted* data type. But then I went AWOL and 
> didn't pursue the matter. I don't know why I was so negligent.
> 
> So this post is to ask: does anyone else think this is bizarre? I'm 
> inclined to make a proposal to add the keyword, but I thought I'd test 
> the waters first.
> 
>  
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
> 


More information about the ghc-steering-committee mailing list