Illegal use of linear functions [GHC31574]
Starting with version 9.0, GHC supports linear types.
These types allow the programmer to express how often the argument to a function is used in the function body.
For this reason, a new function type a %1 > b
has been introduced which stands for linear functions which use their argument of type a
exactly once.
In order to use these functions, however, the extension LinearTypes
has to be enabled.
Examples
Linear identity function needs LinearTypes extension
In this example, the programmer correctly implemented the identity function with a linear type signature.
This type signature correctly states that the identity function uses its argument exactly once.
In order to be able to use this type signature, the extension LinearTypes
has to be enabled.
messages/GHC31574/linearIdentity/before/LinearIdentity.hs:3:21: error: [GHC31574]
Illegal use of linear functions
Suggested fix: Perhaps you intended to use LinearTypes

3  linearIdentity :: a %1 > a

LinearIdentity.hs
Before
module LinearIdentity where
linearIdentity :: a %1 > a
linearIdentity x = x
After
{# LANGUAGE LinearTypes #}
module LinearIdentity where
linearIdentity :: a %1 > a
linearIdentity x = x