Skip to content
GitLab
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 5,255
    • Issues 5,255
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 562
    • Merge requests 562
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9453
Closed
Open
Issue created Aug 17, 2014 by Feuerbach@trac-Feuerbach

The example for GHC Generics is kinda broken

From http://www.reddit.com/r/haskell/comments/2douzn/problem_with_popular_ghcgenerics_example/:

The popular GHC.Generics serialization example at http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-programming.html\#idp25226064 illustrates how to serialize a sum datatype (a :+: b), with a 0 bit representing a and a 1 bit representing b.

However, consider a :+: b :+: c.

If the compiler treats this as (a :+: b) :+: c, then a is 00, b is 01, c is 1.

If it's a :+: (b :+: c), then a is 0, b is 10, c is 11.

The compiler's decision, even though (as I understand it) consistent for any given compile, could differ later.

The manual, at http://hackage.haskell.org/package/generic-deriving-1.6.3/docs/Generics-Deriving-Base.html\#g:9 states not to depend on the ordering, which the example does.

I think this is a valid concern, and the manual should be at least updated to discuss this problem.

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Documentation
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
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