Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,323
    • Issues 4,323
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 363
    • Merge Requests 363
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2358

Closed
Open
Opened Jun 13, 2008 by alfonso.acosta@gmail.com@trac-alfonso.acosta

Template Haskell's TupleT considers unary tuples as a valid types.

I don't know how tuples are internally implemented in GHC, but the Haskell report (3.8) specifically establishes two as their lower size bound.

When provided a zero (or null list) arguments, all TupleT, TupP and TupE behave like the unit type (which is certainly reasonable). However, they handle argument 1 (or the singleton list) in different ways:

  • TupleP [pat] is equivalent to pat (which again, is perfectly reasonable)
  • TupE [exp] behaves as exp (again, it seems right)

However:

  • TupleT 1 AppT VarT ''Int is a different type than VarT ''Int

See the following two examples:

  1. tupE [exp] behaves as expected:
Prelude Language.Haskell.TH> $(sigE (tupE [[|1|]]) (conT ''Int))
1
  1. tupleT 1 doesn't:
Prelude Language.Haskell.TH> $(sigE [|1|] (tupleT 1 `appT` conT ''Int))

<interactive>:1:2:
    No instance for (Num (Int))
      arising from the literal `1' at <interactive>:1:2-40
    Possible fix: add an instance declaration for (Num (Int))
    In the expression: $(sigE [| 1 |] (tupleT 1 `appT` conT 'Int))
    In the definition of `it':
        it = $(sigE [| 1 |] (tupleT 1 `appT` conT 'Int))

Probably, since unary tuples are not legal, the typechecker should simply raise an error when TupleT is found to have received 1 as argument.

Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
Assignee
Assign to
6.8 branch
Milestone
6.8 branch
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#2358