[GHC] #4459: Polymorphic Data.Dynamic

GHC cvs-ghc at haskell.org
Fri Jul 8 04:29:26 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):

 Replying to [comment:14 simonpj]:
 >
 {{{
 \(x :: forall a. Ord a => [a] -> [a]) -> (x :: [ty] -> [ty]
 }}}
       where `ty` is the type you want to instantiate `sort` at.
     * Use GHCi to typecheck and compile this
     * Apply it to the polymorphic `sort`.  That will give you a sort of
 type `[ty] -> [ty]`.
 >
 in implementing the `dynApply` function, the first value should be a
 function value.  I am able to take the types of the two arguments and
 possibly extract a substitution.  For the above example, the substitution
 would be `[ty/a]`.  This substitution gives me the information that the
 `Ord a` class should be turned into the `Ord ty` dictionary.  Which is
 where the above point from Simon PJ comes.

 I need to conjure up an `Ord Int` dictionary to be able to pass it as the
 first argument to the HValue with type `forall a.Ord a => [a] -> [a]`.  I
 can't see how to do that with the `HsSyn` AST since dictionaries aren't
 part of Haskell syntax.

 Also, there needs to be a new primitive `typeOf :: a -> Type` that takes
 an expression and lowers its type to the value level in order to be able
 to implement `toDynamic` and `fromDynamic`.  It can't be applied until
 after the type-checking phase.

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



More information about the Glasgow-haskell-bugs mailing list