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

#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

#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

#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: | -------------------------------------+------------------------------------- Comment (by goldfire): I think this is expected behavior. Representational equality still falls short of its goal of equating all things with equal representation. For example, `Bool` is not `Coercible` to `data BBool = FFalse | TTrue`, even though `Bool` and `BBool` (plausibly) have the same representation. It's true that `forall a. Int -> Bool` and `Int -> Bool` have the same runtime representation, but they crucially look quite different in Core. A member of `forall a. Int -> Bool` looks like `/\ (a :: Type). \ (x :: Int). ...`, while a member of `Int -> Bool` looks like `\ (x :: Int). ...`. One could imagine extending representational equality in this way (it would be sound, if we get the details right), but I don't think it's worth it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15294#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15294: Unused "foralls" prevent types from being Coercible -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: wontfix | 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: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * status: new => closed * resolution: => wontfix Comment: Ah yeah I see the difficulty, I wanted to make sure :) thanks for the response closing -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15294#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC