[GHC] #14292: Coercing between constraints of newtypes

GHC ghc-devs at haskell.org
Wed Sep 27 17:15:53 UTC 2017


#14292: Coercing between constraints of newtypes
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           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:
-------------------------------------+-------------------------------------
 This doesn't work

 {{{#!hs
 {-# Language ConstraintKinds #-}
 {-# Language GADTs #-}

 import Data.Coerce

 newtype USD = USD Int

 data Dict c where
   Dict :: c => Dict c

 num :: Dict (Num Int) -> Dict (Num USD)
 num = coerce
 }}}

 but this does

 {{{#!hs
 data NUM a = NUM (a -> a -> a)

 num' :: NUM Int -> NUM USD
 num' = coerce
 }}}

 is this a fundamental limitation?

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


More information about the ghc-tickets mailing list