dfordivam
dfordivam

Reputation: 169

Alex wrappers.hs no instance of Applicative

I am trying to compile a lex.x with ghc 7.10.2 and alex 3.1.4, but it is giving the below error. I checked Lex.hs and indeed there is no applicative instance for 'Alex' there.

Note: This error started coming after I moved from wrapper 'monad' to 'monad-bytestring'

templates/wrappers.hs:287:10:
    No instance for (Applicative Alex)
      arising from the superclasses of an instance declaration
    In the instance declaration for ‘Monad Alex’

I saw that in alex 3.1.4 this was fixed http://hackage.haskell.org/package/alex

Changes in 3.1.4:

    Add Applicative/Functor instances for GHC 7.10

Below commit introduced the applicative instance, but it is not present in my generated Lex.hs. Can I manually use the below wrapper to be used for generating Lex.hs?

https://github.com/simonmar/alex/commit/b1472bfbb7b95bcd6c66558197e2603997d9ce0b

Upvotes: 1

Views: 117

Answers (1)

dfordivam
dfordivam

Reputation: 169

This is a workaround for this problem. Basically this involves building the alex from latest source code and modifying the local wrapper. Though this worked for me, but it can have some unknown issues also.

mkdir tmp; cd tmp;
git clone https://github.com/simonmar/alex.git
cd alex;
git checkout 3b7e8e4; 
cabal build;

Then copy the 'AlexWrapper-monad-bytestring' generated in this directory to the one in your local alex installation. For example

cp AlexWrapper-monad-bytestring ~/.stack/snapshots/x86_64-linux/lts-3.14/7.10.2/share/x86_64-linux-ghc-7.10.2/alex-3.1.4/AlexWrapper-monad-bytestring

The reason behind building from '3b7e8e4' is that the commit '447bbb8' breaks the compilation of wrapper due to introduction of an extra feature.

Upvotes: 1

Related Questions