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 458
    • Merge requests 458
  • 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
  • #21380
Closed
Open
Created Apr 12, 2022 by Teo Camarasu@teoContributor

template-haskell: reifyConStrictness classifies unlifted typed field as DecidedLazy

Summary

reifyConStrictness is a function that takes the name of a constructor and gives us the strictness information of the fields from the point of view of the compiler (as opposed to telling us what source annotations the fields were given).

I was surprised to find that for I#, we get [DecidedLazy]. I would have expected to be told that this field is DecidedStrict as an Int# value cannot be bottom. Admittedly terms like strict and lazy don't make much sense in the presence of unlifted types.

Even if you add explicit bang patterns, you still get told unlifted fields are DecidedLazy, which makes sense as bang patterns would do nothing for an unlifted field.

This can be worked around by checking if the type of a field is unlifted, but this is an unnecessarily confusing edge case.

Steps to reproduce

run the following ghci script

:set -XTemplateHaskell -XMagicHash
import Language.Haskell.TH.Syntax
import GHC.Exts
$(lift . show =<< reifyConStrictness 'I#)

The output is "[DecidedLazy]"

Expected behavior

I would expect the output to be "[DecidedStrict]" or maybe we could introduce a new constructor called something like DecidedUnlifted for this case.

Environment

  • GHC version used: 9.2.1
Edited Apr 12, 2022 by Teo Camarasu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking