#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]: > * When unwrapping an overloaded polymorphic value at runtime, you'd need to build a suitable dictionary to apply it to. This is no easy matter: you might need the dictionary for `(Ord (Tree [Maybe Int]))`, say. That is, you need to invoke the full type-constraint solver, in the correct type environment. > > If you wanted to solve the latter problem, I think you could get close like this > * Construct the `HsSyn` syntax tree for > {{{ > \(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]`. Am I correct in reading this as an `adaptor` function that is applied to the ad-hoc polymorphic function to render it into the correct monomorphic instance at application site? Do dictionaries get passed as arguments to ad-hoc polymorphic functions? Where is the best place in the code base for me to figure out how GHC implements dictionary-passing? Also, I'm pretty sure there needs to be a new primitive, say `typeOf` that, after type-checking, takes the type of an expression and lowers it to a value to be wrapped in the Dynamic datatype. Where is the best place to do that? -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4459#comment:17> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs