[GHC] #16208: map/coerce does not fire with all newtypes

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider a slightly modified version of T2110, compiled with -O: {{{ #!haskell {-# LANGUAGE GADTs #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE RankNTypes #-} import GHC.Exts import Unsafe.Coerce newtype Age a b where Age :: forall a b. Int -> Age a b foo :: [Int] -> [Int] foo = map id fooAge :: [Int] -> [Age a b] fooAge = map Age fooCoerce :: [Int] -> [Age a b] fooCoerce = map coerce fooUnsafeCoerce :: [Int] -> [Age a b] fooUnsafeCoerce = map unsafeCoerce same :: a -> b -> IO () same x y = case reallyUnsafePtrEquality# (unsafeCoerce x) y of 1# -> putStrLn "yes" _ -> putStrLn "no" main = do let l = [1,2,3] same (foo l) l same (fooAge l) l same (fooCoerce l) l same (fooUnsafeCoerce l) l }}} This code correctly prints "yes" four times, as required by #2110. However, changing the order of type arguments in the definition of Age to: {{{ Age :: forall b a. Int -> Age a b }}} causes the test to fail in one case: `map Age` is no longer simplified to `Age`. The reason is that this change causes the newtype `Age` to have a wrapper, and the map/coerce rule is not detecting it (see Note [Getting the map/coerce RULE to work] and Note [Data con wrappers and GADT syntax]) This ticket is a prerequisite to linear types (since in linear types, all newtypes have wrappers). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: 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 simonpj): Kryztoph, let me know if you need help diagnosing this. Or maybe you already know what is going on. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: 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 aspiwack): * cc: aspiwack (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/377 -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => patch * differential: => https://gitlab.haskell.org/ghc/ghc/merge_requests/377 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/453 -------------------------------------+------------------------------------- Changes (by monoidal): * differential: https://gitlab.haskell.org/ghc/ghc/merge_requests/377 => https://gitlab.haskell.org/ghc/ghc/merge_requests/453 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_run/T16208 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/453 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: => simplCore/should_run/T16208 * resolution: => fixed * milestone: => 8.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes -------------------------------------+------------------------------------- Reporter: monoidal | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_run/T16208 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/453 -------------------------------------+------------------------------------- Comment (by RyanGlScott): Landed in [https://gitlab.haskell.org/ghc/ghc/commit/646b6dfbe125aa756a935e840979ba11b4... 646b6dfb]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16208#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16208: map/coerce does not fire with all newtypes
-------------------------------------+-------------------------------------
Reporter: monoidal | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| simplCore/should_run/T16208
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/453
-------------------------------------+-------------------------------------
Comment (by Marge Bot
participants (1)
-
GHC