Where can I find the list of reserved Haskell keywords as [String]
ghc, haskell
Solution
hscolour uses such a simple list for its `tokenise` function.
keywords =
["case","class","data","default","deriving","do","else","forall"
,"if","import","in","infix","infixl","infixr","instance","let","module"
,"newtype","of","qualified","then","type","where","_"
,"foreign","ccall","as","safe","unsafe"]
keyglyphs =
["..","::","=","\\","|","<-","->","@","~","=>","[","]"]
layoutchars =
map (:[]) ";{}(),"
symbols =
"!#$%&*+./<=>?@\\^|-~"
You can just
import Language.Haskell.HsColour.Classify
isKeyword :: String -> Bool
isKeyword = (== [Keyword]) . map fst . tokenise
Problem
I'm generated some haskell code (in haskell) and I need to be able to detect name which clash with haskell keyword. Is there somewhere to programmatically check if a String is an Haskell keyword ? I could of course compile the list of them myself, but I don't like to reinvent the wheel. Moreover, if new keyword are introduced (by extensions or in new specification) I would like this list to be updated automatically.