- Exploring in GHCi
- Clarifying point-free functions
- Resolving type ambiguity
- Increasing type safety
- 7 minutes
TypeApplications allows you to instantiate one or more of a polymorphic function’s type arguments to a specific type. Use the
@ keyword to apply the function to a type. This has a lot of benefits both for learning and for writing code.
TypeApplications GHC extension first appeared in GHC 8.0.1.GHC documentation for
Exploring in GHCi
Type applications can be especially helpful in the REPL as you’re learning new functions and typeclasses.
λ> :set -XTypeApplications λ> :type (<*>) @ (<*>) @ :: [a -> b] -> [a] -> [b] λ> :type (>>=) @Maybe (>>=) @Maybe :: Maybe a -> (a -> Maybe b) -> Maybe b