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,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • 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
  • #9118

Closed
Open
Opened May 15, 2014 by Richard Eisenberg@raeDeveloper

Can't eta-reduce representational coercions

When I say

import Data.Type.Coercion
import Data.Coerce
import Data.Proxy

eta2 :: Coercible (f a) (g a) => Proxy a -> Coercion f g
eta2 _ = Coercion

I get

    Could not coerce from ‘f’ to ‘g’
      because ‘f’ and ‘g’ are different types.
      arising from a use of ‘Coercion’
    from the context (Coercible (f a) (g a))
      bound by the type signature for
                 eta2 :: Coercible (f a) (g a) => Proxy a -> Coercion f g
      at /Users/rae/temp/Roles.hs:5:9-56
    In the expression: Coercion
    In an equation for ‘eta2’: eta2 _ = Coercion

Unlike the case for #9117 (closed), this one is not expressible in Core. (At least, I don't see a way to do it.) So, to do this, we would have to update Core and then update the constraint solver. I do think this would be type safe. But, I also think it's reasonable to wait for someone with a real use case to shout before doing this. The only use case I have is to be able to do this:

-- says that a's parameter is representational
class Rep (a :: k1 -> k2) where
  co :: Coercible x y => Coercible (a x) (a x)

instance Rep f => Rep (Compose f) where ...
Edited Mar 09, 2019 by Simon Peyton Jones
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9118