[GHC] #15294: Unused "foralls" prevent types from being Coercible

GHC ghc-devs at haskell.org
Wed Jun 20 14:46:57 UTC 2018


#15294: Unused "foralls" prevent types from being Coercible
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.3
           Keywords:  Roles          |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Just a quick question, do these have the same representation?

 {{{#!hs
 newtype A where
   A :: (Int -> Bool) -> A

 newtype B where
   B :: (forall (a::Type). Int -> Bool) -> B
 }}}

 I'm wondering because they aren't `Coercible`

 {{{
 > :t coerce :: A -> B

 <interactive>:1:1: error:
     • Couldn't match representation of type ‘forall a. Int -> Bool’
                                with that of ‘Int -> Bool’
         arising from a use of ‘coerce’
     • In the expression: coerce :: A -> B
 }}}

 What about a new type `C`, that isn't `Coercible` to `B` either

 {{{#!hs
 newtype C where
   C :: (forall k (a :: k). Int -> Bool) -> C
 }}}

 Some is true when it's just the order of variables

 {{{#!hs
 -- D is not Coercible to E, "can't match type ‘Bool’ with ‘Ordering’"

 newtype D where
   D :: (forall (a::Bool) (b::Ordering). Int -> Bool) -> D

 newtype E where
   E :: (forall (a::Ordering) (b::Bool). Int -> Bool) -> E
 }}}

 My question is is this intended?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15294>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list