[Haskell-cafe] alex 3.0 broken with Data.ByteString.Lazy - w2c conversion missing (fix attached)

Eugene Kirpichov ekirpichov at gmail.com
Tue Aug 9 23:24:54 CEST 2011

Hi Simon,

I found a bug in alex-3.0 and I'm attaching a fixed source file -
templates/wrappers.hs (modified against alex-3.0 from cabal unpack).

I was installing bytestring-lexing 0.2.1 and it failed to install with
alex 3.0, which was released on Aug 4.
It succeeded, however, with the most recent earlier alex 2.3.5.

Turns out that the wrapper for lazy bytestrings (strict are ok) had
alexGetByte not doing w2c conversion:
alexGetByte (_, cs) | ByteString.null cs = Nothing
                    | otherwise          = Just (ByteString.head cs,
(ByteString.head cs, ByteString.tail cs))

It should say ByteString.w2c $ ByteString.head cs here.
With this and an additional import of Data.ByteString.Internal (w2c),
the generated code compiles.

To reproduce, cabal unpack bytestring-lexing and try installing it.
Installation will fail, then manually alex the .x files in
Data/ByteString/Lex{,/Lazy} and try ghci'ing to them, doing the
modification I did and ghci'ing again.

Eugene Kirpichov
Principal Engineer, Mirantis Inc. http://www.mirantis.com/
Editor, http://fprog.ru/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrappers.hs
Type: application/octet-stream
Size: 14803 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110809/0a188445/attachment-0001.obj>

More information about the Haskell-Cafe mailing list