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,392
    • Issues 4,392
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 374
    • Merge Requests 374
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #3176

Closed
Open
Opened Apr 19, 2009 by claus.reinke@talk21.com@trac-claus.reinke

erroneous defaulting? behaviour for existentials

consider

{-# LANGUAGE NoExtendedDefaultRules #-}
{-# OPTIONS_GHC -fwarn-type-defaults #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ExistentialQuantification #-}

data EShow = forall a. Show a => EShow a

smallPrint t = concatMap (\f-> case f t of EShow a -> show a) [EShow . foo, EShow . bar, EShow . baz]

data ES = forall a. Show a => ES {unES:: a}

smallPrintES t = concatMap (\f-> show $ unES $ f t) [ES . foo, ES . bar, ES . baz]

data Test = Test { foo :: Int, bar :: Char, baz :: Bool }

main = print $ smallPrintES $ Test 1 'x' False

for which

$ /cygdrive/c/ghc/ghc-6.11.20090320/bin/ghc -e "main" exists.hs
"()()()"

while

$ /cygdrive/c/ghc/ghc-6.8.3/bin/ghc -e "main" exists.hs

exists.hs:12:40:
    Cannot use record selector `unES' as a function due to escaped type variables
    Probably fix: use pattern-matching syntax instead
    In the first argument of `($)', namely `unES'
    In the second argument of `($)', namely `unES $ f t'
    In the expression: show $ unES $ f t

The expected results were error message or this

$ /cygdrive/c/ghc/ghc-6.11.20090320/bin/ghc -e "smallPrint $ Test 1 'x' False" exists.hs
"1'x'False"

There seem to be two issues:

  • shouldn't ghc head report the use of unES as an error?

  • how does ghc head arrive at that result, with these flags, without any warnings?

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