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,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 381
    • Merge Requests 381
  • 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
  • #16501

Closed
Open
Opened Mar 26, 2019 by Iavor S. Diatchki@yavDeveloper

Record updates for existential fields do not work + confusing error

It would appear that updating a field with an existentially quantified type does not work, when using the record update notation. Here is an example:

{-# Language GADTs #-} -- Only uses Existentials
  
data T where
  Str :: Show s => { field :: s } -> T

val1 :: T
val1 = Str { field = True }

{-
val2 :: T
val2 = val1 { field = 'a' }
  • Record update for insufficiently polymorphic field: field :: s
    • In the expression: val1 {field = 'a'}
      In an equation for ‘val2’: val2 = val1 {field = 'a'}
-}

manualUpdate :: Show s => T -> s -> T
manualUpdate (Str _) s = Str s

val3 :: T
val3 = manualUpdate val1 'a'

Is there a reason why this shouldn't work? I would imagine that we'd like the record update to behave just like manualUpdate in the example.

Also, the error seems quite odd: how can a field be "insufficiently polymorphic"? After all, it is ok to update completely monomorphic fields.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16501