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,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 451
    • Merge requests 451
  • 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
  • #10868
Closed
Open
Created Sep 11, 2015 by Ryan Scott@RyanGlScottMaintainer

Make GHC generics capable of handling unboxed types

Currently, GHC generics will not accept any unboxed constructor arguments:

$ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
λ> :set -XMagicHash -XDeriveGeneric
λ> :m + GHC.Generics GHC.Exts
λ> data IntHash = IntHash Int# deriving Generic

<interactive>:4:38:
    Can't make a derived instance of ‘Generic IntHash’:
      IntHash must not have unlifted or polymorphic arguments
    In the data declaration for ‘IntHash’

This makes GHC generics strictly less powerful than deriving clauses in some scenarios, as typeclasses like Eq, Ord, and Show are capable of special-casing certain unboxed types:

λ> :set -ddump-deriv
λ> data IntHash = IntHash Int# deriving Show

==================== Derived instances ====================
Derived instances:
  instance GHC.Show.Show Ghci1.IntHash where
    GHC.Show.showsPrec a_a1OJ (Ghci1.IntHash b1_a1OK)
      = GHC.Show.showParen
          ((a_a1OJ GHC.Classes.>= 11))
          ((GHC.Base..)
             (GHC.Show.showString "IntHash ")
             (GHC.Show.showsPrec 11 (GHC.Types.I# b1_a1OK)))
    GHC.Show.showList = GHC.Show.showList__ (GHC.Show.showsPrec 0)

As discussed on the GHC devs mailing list previously, Andres suggested adding new generic representation types to mark where Int#, Char#, etc. are used (suggesting the name UInt to represent Int#).

Trac metadata
Trac field Value
Version 7.10.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC dreixel, kosmikus
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking