Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,869
    • Issues 4,869
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10697
Closed
Open
Created Jul 28, 2015 by Ryan Scott@RyanGlScottMaintainer

Change template-haskell API to allow NOUNPACK, lazy annotations

Currently, the template-haskell API is lagging behind what is possible with GHC's strictness annotations in data types, especially since the advent of StrictData. Currently, template-haskell has Strict:

data Strict
  = IsStrict	 
  | NotStrict	 
  | Unpacked

But it appears that there are actually nine different combinations of packedness and strictness annotations:

data A = A                   Int -- No unpackedness, no strictness
data A = A                  !Int -- No unpackedness, strict
data A = A                  ~Int -- No unpackedness, lazy
data A = A {-# NOUNPACK #-}  Int -- NOUNPACK, no strictness
data A = A {-# NOUNPACK #-} !Int -- NOUNPACK, strict
data A = A {-# NOUNPACK #-} ~Int -- NOUNPACK, lazy
data A = A {-#   UNPACK #-}  Int -- UNPACK, no strictness
data A = A {-#   UNPACK #-} !Int -- UNPACK, strict
data A = A {-#   UNPACK #-} ~Int -- UNPACK, lazy

It seems like the most consistent thing to do would be change Strict and add Unpack to the template-haskell API:

data Strict
  = IsStrict
  | IsLazy
  | NoStrictAnnot

data Unpack
  = Unpack
  | NoUnpack
  | NoUnpackAnnot

type UnpackStrict        = (Unpack, Strict)
type UnpackStrictType    = (UnpackStrict, Type)
type VarUnpackStrictType = (Name, UnpackStrict, Type)

type StrictType    = UnpackStrictType
type VarStrictType = VarUnpackStrictType

And so on.

Edited Mar 10, 2019 by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking