
#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 facundo.dominguez): Replying to [comment:12 simonpj]:
* I'd love a wiki page summarising the programmer's-eye-view of the design; ...
Good suggestion.
* What is `addrToAny#` and where is it documented?
* ... So I think it'd be better if the desugarer did the floating, not
Found here: http://www.haskell.org/ghc/docs/latest/html/libraries/ghc-prim-0.3.1.0 /GHC-Prim.html#v:addrToAny-35- the type checker. That should not be a hard change to make. Sure, we can try it.
* I don't understand `checkStaticValues`. The typing rule for `static` in the paper is quite simple, so what is going on here?
One of the major design choices we had to make is how to handle qualified types. Say we have the expression `static return`, we had to choose between giving it types like: {{{ static return :: Ref (Monad m => a -> m a) static return :: Monad m => Ref (a -> m a) }}} or disallowed them completely. The last option looked the simplest while still useful, so we disallowed static forms whose bodies have qualified types. Now, say we want to type- check an expression like {{{ f :: Ref (a -> IO a) f = static return }}} We expect the expression `return` to have type `a -> IO a`. Yet we don't know if the type of `return` will be qualified or not until the whole definition of `f` is type-checked. `f` could have more equations and no type signature, or we may even have to wait for the whole module to be type-checked because of the monomorphism restriction. `checkStaticValues` is the piece of the implementation that considers if the body of the static form has a qualified type. And this, we understand, is only practical to do after the whole module has been type-checked.
* I'm pretty convinced that static values (`Refs`) should come with a `TypeRep` ...
In case you mean Data.Typeable.TypeRep, how could we deal with static forms whose bodies have a polymorphic type?
Bikeshed: ...
I leave this for later. Thanks for looking at the implementation. It really needs the feedback. And probably, we should document better the design and discuss it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7015#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler