[GHC] #4459: Polymorphic Data.Dynamic

GHC cvs-ghc at haskell.org
Wed Jun 29 03:30:18 CEST 2011


#4459: Polymorphic Data.Dynamic
-----------------------------------------------------+----------------------
    Reporter:  vivian                                |        Owner:  vivian      
        Type:  feature request                       |       Status:  new         
    Priority:  normal                                |    Milestone:  7.4.1       
   Component:  GHC API                               |      Version:  7.1         
    Keywords:  polymorphic, dynamic, class, linking  |     Testcase:              
   Blockedby:                                        |   Difficulty:              
          Os:  Unknown/Multiple                      |     Blocking:  4316        
Architecture:  Unknown/Multiple                      |      Failure:  None/Unknown
-----------------------------------------------------+----------------------

Comment(by vivian):

 {{{
 spin    ::          [a] -> [a]
 spinOrd :: Ord a => [a] -> [a]
 alist   :: [Int]
 }}}

 So far I am able to dynamically load `spin` and `alist` and successfully
 print the result of the application of the parametrically polymorphic
 function `spin` to `alist`.

 The problem (as pointed out in the reference given by simonmar above) is
 ad-hoc polymorphism (`spinOrd`).

   1) How is the class information stored in an interface file?

   2) How does the linker normally go about finding the correct instance of
 an overloaded function such as `<`?

 If I have the `Type` of both `spinOrd` and `alist` then I can us
 `mkAppyTy` to unify the two types and there will be a substitution
 `[Int/a](Ord a => [a] -> [a])` --> `Ord Int => [Int] -> [Int]` that tells
 me to use the `Ord Int` dictionary.  I need to somehow use this
 information to 'specialise' the `spinOrd` function with methods from the
 `Ord Int` dictionary before the function is applied to the argument, which
 is done by the dynamic linker.

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



More information about the Glasgow-haskell-bugs mailing list