[GHC] #9429: Alternative to type family Any
GHC
ghc-devs at haskell.org
Tue Aug 12 22:43:31 UTC 2014
#9429: Alternative to type family Any
-------------------------------------+-------------------------------------
Reporter: mboes | Owner:
Type: feature | Status: new
request | Milestone:
Priority: normal | Version: 7.9
Component: Compiler | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets: 9097, 9380
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by mboes):
Replying to [comment:10 carter]:
> ok, now if we had a hypothetical `PolyTypeable` would you have other
remaining needs for Any?
I myself wouldn't. I don't know of other use cases beyond the ones
internal to GHC.
> It occurs to me as I'm saying this, that to some extent PolyTypeable is
possible today via data/newtype wrapping a polymorphic type! For you use
case, Is that a viable solution today (aesthetics aside) or is there a
fundamental barrier to that being suitable?
Interesting idea. But I'm afraid it isn't a solution without its problems,
beyond the mere verbosity that it might induce.
If I understand your idea correctly, you're saying that if you want to
send say `bind`, then you introduce the following type and wrap `bind`:
{{{
data Dict c = c => Dict
newtype BindWrap = BindWrap (forall a m. Dict (Monad m) -> m a -> (a -> m
b) -> m b)
bindWrap = BindWrap $ \Dict -> (>>=)
}}}
Now, you can send a label for `bindWrap` to the remote side, along with
the `TypeRep` for `BindWrap`.
But you can't compose `bindWrap`. That is, `bindWrap` is a "static value"
in the sense that it doesn't depend on any other runtime "dynamic" value.
In other words, it has no free variables. If we say that labels for static
values `x :: a` have type `Static a`, then I can't combine `bindWrap` with
say `action :: Static [Int]` using
{{{
staticApply :: Static (a -> b) -> Static a -> Static b
}}}
because `bindWrap` is of atomic type. The only reasonable type that I can
give to any label for it is `Static BindWrap`. But that's not a `Static`
with an arrow type index.
So while you can send `bindWrap`, you can't send compositions of it with
other `Static` things. This is an important feature for many Cloud Haskell
use cases.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9429#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list