Illegal standalone kind signature [GHC-45906]
Standalone kind signatures can be used to specify a polymorphic kind for a type, to overcome kind inference restrictions:
type T :: (k -> Type) -> k -> Type -- standalone kind signature
data T m a = MkT (m a) (T Maybe (m a))Without the standalone kind signature, GHC would infer the kind
T :: (Type -> Type) -> Type -> Type.
Use of this feature requires the StandaloneKindSignatures
extension to be enabled. This extension is implied by
UnliftedDatatypes, and included in the GHC2021 and GHC2024
language editions.
Examples
Illegal standalone kind signature
Module fails to compile because it contains a standalone type signature.
Error Message
SAKS.hs:7:1: error: [GHC-45906]
Illegal standalone kind signature
Suggested fix:
Perhaps you intended to use the ‘StandaloneKindSignatures’ extension (implied by ‘UnliftedDatatypes’)SAKS.hs
Before
{-# LANGUAGE Haskell2010 #-}
module SAKS where
import Data.Kind (Type)
type T :: Type
data T
After
{-# LANGUAGE GHC2021 #-}
module SAKS where
import Data.Kind (Type)
type T :: Type
data T