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

GHC ghc-devs at haskell.org
Wed Jun 20 14:56:17 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
      Resolution:                    |             Keywords:  Roles
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

Old description:

> 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?

New description:

 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
 }}}

 `C` isn't `Coercible` to `B` either

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

 Also

 {{{#!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#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list