Changes between Initial Version and Version 2 of Ticket #14790


Ignore:
Timestamp:
Feb 11, 2018 10:52:48 AM (20 months ago)
Author:
dfeuer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14790 – Description

    initial v2  
    66
    77{{{#!hs
    8 {-# language GADTs, ScopedTypeVariables, TypeApplications #-}
     8{-# language GADTs, ScopedTypeVariables, TypeApplications,
     9       AllowAmbiguousTypes #-}
    910module Foo where
    1011import Type.Reflection
    1112
    12 foo :: forall proxy a. Typeable a => proxy a -> Bool
    13 foo _ = case eqTypeRep (typeRep @a) (typeRep @Int) of
     13foo :: forall a. Typeable a => Bool
     14foo = case eqTypeRep (typeRep @a) (typeRep @Int) of
    1415          Just _ -> True
    1516          Nothing -> False
    16 
    1717}}}
    1818
     
    2020
    2121{{{
     22foo [InlPrag=NOINLINE] :: forall a. Typeable a => Bool
     23[GblId, Arity=1, Str=<S,1*U>]
    2224foo
    23   = \ (@ (proxy_a6tT :: * -> *))
    24       (@ a_a6tU)
    25       ($dTypeable_a6tW :: Typeable a_a6tU) ->
    26       let {
    27         lvl_s6Sc :: Maybe (a_a6tU :~~: Int)
    28         [LclId]
    29         lvl_s6Sc
    30           = eqTypeRep
    31               @ *
    32               @ *
    33               @ a_a6tU
    34               @ Int
    35               ($dTypeable_a6tW
    36                `cast` (base-4.11.0.0:Data.Typeable.Internal.N:Typeable[0] <*>_N <a_a6tU>_N
    37                        :: (Typeable a_a6tU :: Constraint) ~R# (TypeRep a_a6tU :: *)))
    38               Foo.foo1 } in
    39       \ _ [Occ=Dead] ->
    40         case lvl_s6Sc of {
    41           Nothing -> GHC.Types.False;
    42           Just ds1_d6Rq -> GHC.Types.True
    43         }
     25  = \ (@ a_a5un) ($dTypeable_a5up :: Typeable a_a5un) ->
     26      case eqTypeRep
     27             @ *
     28             @ *
     29             @ a_a5un
     30             @ Int
     31             ($dTypeable_a5up
     32              `cast` (base-4.10.1.0:Data.Typeable.Internal.N:Typeable[0] <*>_N <a_a5un>_N
     33                      :: (Typeable a_a5un :: Constraint) ~R# (TypeRep a_a5un :: *)))
     34             lvl4_r69g
     35      of {
     36        Nothing -> GHC.Types.False;
     37        Just ds_d5CQ -> GHC.Types.True
     38      }
     39
    4440}}}
    45 
    46 For reference, `eqTypeRep` is defined like this:
    47 
    48 {{{#!hs
    49 eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2).
    50              TypeRep a -> TypeRep b -> Maybe (a :~~: b)
    51 eqTypeRep a b
    52   | typeRepFingerprint a == typeRepFingerprint b = Just (unsafeCoerce HRefl)
    53   | otherwise                                    = Nothing
    54 }}}