Visible type applications

Contents
  • Exploring in GHCi
  • Clarifying point-free functions
  • Resolving type ambiguity
  • Increasing type safety
Video
  • 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.

The TypeApplications GHC extension first appeared in GHC 8.0.1.GHC documentation for TypeApplications

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

Sign up for access to the full page, plus the complete archive and all the latest content.