user997225
user997225

Reputation:

How can I enable GHC extensions in a literate Haskell script?

I'm working on a literate Haskell script that defines a Grammar datatype that is to be loaded into GHCI (v. 7.8.3) on my Mac. I am trying to turn on language extensions called KindSignatures and GADTs in my script (I am completely unfamiliar with these) but I've been advised to include the line

{-# LANGUAGE KindSignatures, GADTs #-}

at the top of my script. But I get an error message:

Grammars.lhs:5:3:
    Illegal kind signature ‘Grammar’
      (Use KindSignatures to allow kind signatures)
    In the data declaration for ‘Grammar’
Failed, modules loaded: none.

Could someone please tell me what I'm doing wrong? Also is there any kind of documentation on KindSignatures or GADTs? I've been unable to find much.

Upvotes: 5

Views: 421

Answers (1)

Ørjan Johansen
Ørjan Johansen

Reputation: 18189

Since it is a literate script, you need to escape the pragma like other literate code:

> {-# LANGUAGE KindSignatures, GADTs #-}

or

\begin{code}
{-# LANGUAGE KindSignatures, GADTs #-}
\end{code}

dependent on which literate style you are using.

Upvotes: 8

Related Questions