haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
298 stars 82 forks source link

Introduce strict-text and posn-strict-text wrappers and monadUserState-strict-text #240

Closed alexbiehl closed 1 year ago

alexbiehl commented 1 year ago

This PR introduces the strict-text and posn-strict-text wrappers to allows working with Data.Text out of the box.

Implementation wise we could do a bit better by using Data.Text.Foreign.takeWord8 and avoiding the intermediate list of bytes in a codepoint but this will do for now.

alexbiehl commented 1 year ago

~Hm, tests do pass locally, not sure what's causing the issue.~

andreasabel commented 1 year ago

(As you already noticed) text is only a GHC-shipped package from 8.4 on, compare the release notes:

Adding a dependency like text might require to cabalize the testsuite first. (It's Makefile design is ancient, probably predating cabal.)

alexbiehl commented 1 year ago

@andreasabel It looks like to fully cabalize the test suite is a long term effort, how about I disable the text specific tests on old GHCs?

andreasabel commented 1 year ago

how about I disable the text specific tests on old GHCs?

Yes, that seems fair, especially since you add a new feature so it is less important to test it with old GHCs.

alexbiehl commented 1 year ago

Cool! Squash is fine.

andreasabel commented 1 year ago

I now tested this PR locally by porting one of my projects to the new posn-strict-text wrapper. Worked!

andreasabel commented 1 year ago

A new major version (3.4.0.0) looks more appropriate for a new feature, one can then have build-tool-depends: alex:alex >= 3.4 (rather than 3.3.1).