Type application without space [GHC-84077]
Language extension: TypeApplications
Type application syntax requires a space before @
. This is described in the documentation of the visible type application feature.
Examples
Missing space before type application
There is no space before the type application @Int
.
Error Message
MissingSpaceTypeOperator.hs:6:7: error:
@-pattern in expression context: x@Int
Type application syntax requires a space before '@'
|
6 | f x = x@Int
| ^^^^^
MissingSpaceTypeApplication.hs
Before
{-# LANGUAGE TypeApplications #-}
module MissingSpaceTypeApplication where
f :: (forall a. a -> b) -> (Int -> b)
f x = x@Int
After
{-# LANGUAGE TypeApplications #-}
module MissingSpaceTypeApplication where
f :: (forall a. a -> b) -> (Int -> b)
f x = x @Int
Missing space in type application
Error Message
Example.hs:7:5: error:
@-pattern in expression context: g@Int
Type application syntax requires a space before '@'
|
7 | f = g@Int
| ^^^^^
Explanation
A space is missing before the type application. The expression cannot be correctly parsed.
Example.hs
Before
{-# LANGUAGE TypeApplications #-}
module Example where
g :: (Num a) => a -> a
g x = x * 2
f = g@Int
After
{-# LANGUAGE TypeApplications #-}
module Example where
g :: (Num a) => a -> a
g x = x * 2
f = g @Int