Contents
- Example
- Inferring type constructors
- Use during development
- Inferring constraints
- With
StandaloneDeriving
- With
NamedWildCards
- With ScopedTypeVariables
- No warning
In standard Haskell, type inference is a somewhat all-or-nothing affair. You can either omit the type signature for a function and let the compiler infer it:
Or you can write a type signature yourself:
But what if we want to only specify part of the type and let the compiler fill in the blank automatically? The PartialTypeSignatures
extension,GHC documentation for PartialTypeSignatures
available in GHC 7.10 and later, can help.
This lesson shows how to use the PartialTypeSignatures
extension and what kinds of things it can infer. We also discuss why you might want to take advantage of this feature during development so that you code can always compile despite possibly being not all written yet.