Haskell implementors' Workshop edition:6 location:Gothenburg, Sweden date:6 September 2014
In Haskell, programmers have a binary choice between omitting the type signature (and relying on type inference) or explicitly providing the type entirely; there are no intermediate options. Partial type signatures bridge the gap between the two extremes.
In a partial type signature, annotated types can be mixed with inferred types. A type signature is written like before, but can now contain wildcards, written as underscores. Also, placing a wildcard in the constraints part of a type signature will allow the type checker to infer an arbi- trary number of constraints. The type checker will verify that the inferred type matches the form of the partial type signature, while at the same time it infers the types of the wildcards. E.g., a partial type signature _ => a -> _ could lead to the type Show a => a -> String . Partial type signatures give the programmer complete control over the amount of type infor- mation he wants to annotate.
Partial type signatures can be useful in the development phase; the programmer can annotate the parts of the type signature he knows and replace the unknown parts with underscores. They can also be used to hide complex parts of a type signature or to emphasise the relevant annotated parts.
We are currently working on integrating partial type signatures in GHC as a variant of Type- dHoles. Whereas TypedHoles allow holes in programs or expressions, PartialTypeSignatures allow holes in types. Depending on the extensions that are enabled, partial type signatures are considered as either temporary placeholders that need to be replaced with full signatures for the code to be successfully compiled or a permanent way to leave out uninteresting parts of types.
In this presentation, I will give an overview of partial type signatures, and give some insights in the implementation.