Strict unlifted types

Simon Peyton Jones simonpj at microsoft.com
Wed Feb 7 09:08:10 UTC 2018


Sounds similar to https://ghc.haskell.org/trac/ghc/wiki/UnliftedDataTypes

Simon

|  -----Original Message-----
|  From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of
|  David Feuer
|  Sent: 07 February 2018 01:11
|  To: ghc-devs <ghc-devs at haskell.org>
|  Subject: Strict unlifted types
|  
|  Sometimes there's an awkward expressive tension between saying that a
|  type is *unboxed* and saying that it is *strict* in a field. For
|  example, I can write
|  
|  data SMaybe a = SNothing | SJust !a
|  
|  or I can write
|  
|  type Maybe# a = (# (# #) | a #)
|  
|  but there doesn't seem to be a way to simultaneously get both unboxed
|  and strict. I'm wondering if it might make sense to add a type to
|  serve the purpose
|  
|  Strict# :: Type -> TYPE 'UnliftedRep
|  
|  mkStrict# :: a -> Strict# a  -- force the argument getStrict# ::
|  Strict# a -> a  -- do nothing, but know the result is in WHNF
|  
|  Then one could write, for example,
|  
|  type SMaybe# a = (# (# #) | Strict# a #)
|  
|  at which point SMaybe is *precisely* isomorphic to the alternative
|  representation
|  
|  data SMaybe' a = SMaybe' (SMaybe# a)
|  
|  David
|  _______________________________________________
|  ghc-devs mailing list
|  ghc-devs at haskell.org
|  https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.h
|  askell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-
|  devs&data=04%7C01%7Csimonpj%40microsoft.com%7Cdf3667262c11430fef8008d5
|  6dc7c3e7%7Cee3303d7fb734b0c8589bcd847f1c277%7C1%7C0%7C6365356271225789
|  33%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI
|  6Ik1haWwifQ%3D%3D%7C-
|  1&sdata=x736pxmxWrkybgV6xXLjIT9EFnKibMJuiEyJpj1SfSw%3D&reserved=0


More information about the ghc-devs mailing list