
#7015: Add support for 'static' -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.4.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D119 | -------------------------------------+------------------------------------- Comment (by mboes): Replying to [comment:22 simonpj]:
Perhaps we could say, for now, that the argument of static must have no free type variables, just as it has no free term variables (other than top level constants). [...] Now you can continue to do your current hack in the library (pending a better solution for polymorphism), but the GHC part remains simple and clean.
Yes. It occurred to me while falling asleep last night that just as we ban qualified types, we could as well ban polymorphic types. In both cases, these features are "emulated" outside of the compiler (using the `Any` hack and a library implementation of unification in the case of polymorphic functions, passing an explicit `Dict` in the case of overloaded functions). Now, for the `Any` hack to continue working in full generality, we're back to #9429.
I don't fully understand the `Any` business (e.g. how can it possible deal with polymorphic functions with more than one type parameter `forall a b. a -> b -> b`?), but it smells like a hack.
There are two ways to do this (see #9429): define {{{ type Any1 = Any type Any2 = Any Any }}} and then you can encode your type as `Any1 -> Any2 -> Any2`. Alternatively, Edwardk suggests `Any 1 -> Any 2 -> Any 2`, using type- level literals. I like that one better. Whatever we do, for the purposes of Cloud Haskell, it must be possible to have a `Typeable` instance for the resulting type. If `GHC.Exts.Any` becomes a type family, then that's no longer a possibility. See proposed solutions in #9429. No matter what we do there, ideally it should be possible to use the `Any` hack to handle a type like `forall a m. Dict (Monad m) => a -> m a`, for example. Defining a `MyAny :: Nat -> *` type for this purposes is an option, but will only work for type variables of kind `*` and in particular not work for this example. The nice thing about having ''some'' datatype with the same properties as GHC 7.8's `GHC.Exts.Any` (at least for open kinds, not closed kinds, which can't be dealt with), is that the user or libraries don't have to bother defining a proliferation of `MyAny`s, one for each open kind that gets used in the wild. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7015#comment:23 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler