[GHC] #14255: Type-indexed type fingerprints

GHC ghc-devs at haskell.org
Wed Sep 20 13:14:04 UTC 2017


#14255: Type-indexed type fingerprints
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Core Libraries    |              Version:  8.2.1
      Resolution:                    |             Keywords:  Typeable
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 RyanGlScott):

 I assume that by "reduce the size of the trusted codebase", you mean
 eliminating uses of `unsafeCoerce`. But I don't see how indexing
 fingerprints with types would accomplish this. For example, fingerprints
 are used in `eqTypeRep`:

 {{{#!hs
 eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
              TypeRep a -> TypeRep b -> Maybe (a :~~: b)
 eqTypeRep a b
   | typeRepFingerprint a == typeRepFingerprint b = Just (unsafeCoerce
 HRefl)
   | otherwise                                    = Nothing
 }}}

 Are you envisioning changing this to the following?

 {{{#!hs
 eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
              TypeRep a -> TypeRep b -> Maybe (a :~~: b)
 eqTypeRep a b = eq (typeRepFingerprint a) (typeRepFingerprint b)

 eq :: FingerPrintIx a -> FingerPrintIx b -> Maybe (a :~~: b)
 }}}

 If so, then that would axe one use of `unsafeCoerce`... but how are you
 planning to implement `eq`? I'm not sure how you would aside from using
 `unsafeCoerce` again! So we've traded one use of `unsafeCoerce` for
 another.

 Perhaps I'm way off base in my assumptions, so please correct me if you
 had a different vision in mind.

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


More information about the ghc-tickets mailing list