RE: Strict unlifted types

2018-02-07 Thread Simon Peyton Jones via ghc-devs
Sounds similar to https://ghc.haskell.org/trac/ghc/wiki/UnliftedDataTypes

Simon

|  -Original Message-
|  From: ghc-devs [mailto:ghc-devs-boun...@haskell.org] On Behalf Of
|  David Feuer
|  Sent: 07 February 2018 01:11
|  To: ghc-devs <ghc-devs@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@haskell.org
|  https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.h
|  askell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-
|  devs=04%7C01%7Csimonpj%40microsoft.com%7Cdf3667262c11430fef8008d5
|  6dc7c3e7%7Cee3303d7fb734b0c8589bcd847f1c277%7C1%7C0%7C6365356271225789
|  33%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI
|  6Ik1haWwifQ%3D%3D%7C-
|  1=x736pxmxWrkybgV6xXLjIT9EFnKibMJuiEyJpj1SfSw%3D=0
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Strict unlifted types

2018-02-06 Thread David Feuer
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@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs