[GHC] #4459: Polymorphic Data.Dynamic
GHC
cvs-ghc at haskell.org
Tue Jun 28 04:40:53 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:9 simonmar]:
> I'm completely confused about what this ticket is asking for. Could
somebody explain in more detail please? e.g. the ticket seems to be
asking for something in the `Data.Dynamic` library, but then there's lots
of talk about something in the GHC API. What is `TypedAny`?
This ticket is about adding support for polymorphic dynamic types, which
would appear in `Data.Dynamic` or similar as a package, so that, for
example, a variable `sort :: Ord a => [a] -> [a]` can be loaded at runtime
(like `System.Plugins`) and then dynamically linked/typechecked against
the variable to which it is applied. Currently dynamics and plugins are
limited by the monomorphic restriction.
`TypedAny` (renamed to `DynamicHValue`) is supposed to be an opaque type
that wraps an `HValue` and a `Type` via the GHC API. [I have got this
far, i.e. dynamically loaded code via GHC]
[In an early incarnation I was able to apply a dynamically loaded ad hoc
polymorphic function to a list and print the result]
I listed this as a feature request against the GHC API because there need
to be some additions 'under the hood' for this to work:
1) a way of getting the type of an expression to the value level
`ty <- GHC.modInfoLookupName` <-- okay for dynamically loaded code but not
normal code
2) a way of getting a 'type as value' to become the type of an
expression
`(unsafeCoerce hvalue) :: ty` <-- currently completely impossible
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4459#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list