From 59229c256aa035b7b7dd022bb41ddc7ec92b372b Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 3 Aug 2025 21:32:29 +0200 Subject: [PATCH 1/3] Use `Data.Char.{chr,ord}` qualified in generated code --- .gitignore | 1 - data/AlexTemplate.hs | 2 +- data/AlexWrappers.hs | 5 +---- src/Main.hs | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index fdb14dd..c4d5fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ *.dyn_o *.info /.ghc.environment.* -/data/ /dist /dist-newstyle /examples/*.alex.hs diff --git a/data/AlexTemplate.hs b/data/AlexTemplate.hs index 4531449..251c512 100644 --- a/data/AlexTemplate.hs +++ b/data/AlexTemplate.hs @@ -146,7 +146,7 @@ alex_scan_tkn user__ orig_input len input__ s last_acc = Nothing -> (new_acc, input__) Just (c, new_input) -> #ifdef ALEX_DEBUG - Debug.Trace.trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c ++ " " ++ (show . chr . fromIntegral) c) $ + Debug.Trace.trace ("State: " ++ show IBOX(s) ++ ", char: " ++ show c ++ " " ++ (show . Data.Char.chr . fromIntegral) c) $ #endif case fromIntegral c of { IBOX(ord_c) -> let diff --git a/data/AlexWrappers.hs b/data/AlexWrappers.hs index 30ea7be..a8833e6 100644 --- a/data/AlexWrappers.hs +++ b/data/AlexWrappers.hs @@ -17,20 +17,17 @@ import Data.Word (Word8) #if defined(ALEX_BASIC_BYTESTRING) || defined(ALEX_POSN_BYTESTRING) || defined(ALEX_MONAD_BYTESTRING) import Data.Int (Int64) -import qualified Data.Char import qualified Data.ByteString.Lazy as ByteString import qualified Data.ByteString.Internal as ByteString (w2c) #elif defined(ALEX_STRICT_BYTESTRING) -import qualified Data.Char import qualified Data.ByteString as ByteString import qualified Data.ByteString.Internal as ByteString hiding (ByteString) import qualified Data.ByteString.Unsafe as ByteString #else -import Data.Char (ord) import qualified Data.Bits -- | Encode a Haskell String to a list of Word8 values, in UTF8 format. @@ -38,7 +35,7 @@ utf8Encode :: Char -> [Word8] utf8Encode = uncurry (:) . utf8Encode' utf8Encode' :: Char -> (Word8, [Word8]) -utf8Encode' c = case go (ord c) of +utf8Encode' c = case go (Data.Char.ord c) of (x, xs) -> (fromIntegral x, map fromIntegral xs) where go oc diff --git a/src/Main.hs b/src/Main.hs index 493dadf..521fc8d 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -401,6 +401,7 @@ always_imports :: [String] always_imports = [ "#include \"ghcconfig.h\"" , "import qualified Data.Array" + , "import qualified Data.Char" ] import_glaexts :: [String] @@ -437,8 +438,7 @@ import_glaexts = import_debug :: [String] import_debug = - [ "import Data.Char (chr)" - , "import qualified Debug.Trace" + [ "import qualified Debug.Trace" ] templateDir :: IO FilePath -> [CLIFlags] -> IO FilePath From 568d91527ff18c9ec3f4776fd31ad3acc20baaea Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 3 Aug 2025 21:33:10 +0200 Subject: [PATCH 2/3] tests/Makefile: declare .i.hs and .d.hs files as precious --- .gitignore | 6 +++--- tests/Makefile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c4d5fa2..594bbd9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,9 @@ /examples/*.bin /examples/*.exe /old-*/ -/tests/*.[dgn].hs -/tests/*.[dgn].bin -/tests/*.[dgn].exe +/tests/*.[dign].hs +/tests/*.[dign].bin +/tests/*.[dign].exe .cabal-sandbox .stack-work cabal.sandbox.config diff --git a/tests/Makefile b/tests/Makefile index c6adc74..9e11914 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -41,7 +41,7 @@ WARNS_DEP_GHC_GTEQ_9_8:=$(shell if [ $(GHC_MAJOR_VERSION) -gt 9 -o $(GHC_MAJOR_V HC_OPTS=-Wall $(WARNS_DEP_GHC_GTEQ_9_8) -fwarn-incomplete-uni-patterns -Werror -.PRECIOUS: %.n.hs %.g.hs %.o %.exe %.bin +.PRECIOUS: %.d.hs %.i.hs %.g.hs %.n.hs %.o %.exe %.bin ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32" HS_PROG_EXT = .exe From e65958c688ba04f8b14c888d7b55f16532510f51 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 3 Aug 2025 22:17:43 +0200 Subject: [PATCH 3/3] Bump to 3.5.4.0 and CHANGELOG Also cosmetic changes to .cabal file. --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 12 ++++++++++++ alex.cabal | 10 ++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 056079d..2ff609a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - "9.4.8" - "9.6.7" - "9.8.4" - - "9.10.1" + - "9.10.2" - "9.12.2" include: - ghc: "9.12.2" diff --git a/CHANGELOG.md b/CHANGELOG.md index e4ebd1a..ae0d5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## Changes in 3.5.4.0 + +* Fix [issue #277](https://github.com/haskell/alex/issues/277): + compatibility of generated code with `{-# LANGUAGE ImpredicativeTypes #-}`, + thanks Nadia Yvette Chambers! +* Simplify `cabal install` ([PR #272](https://github.com/haskell/alex/pull/272)), + thanks Antoine Leblanc! +* Document `examples/words.x`, thanks Piotr Justyna! +* Tested with GHC 8.0 - 9.12.2. + +_Andreas Abel, 2025-08-03_ + ## Changes in 3.5.3.0 * Fix critical bug in automaton minimizer diff --git a/alex.cabal b/alex.cabal index 1dff816..611c388 100644 --- a/alex.cabal +++ b/alex.cabal @@ -1,6 +1,6 @@ -cabal-version: >= 1.10 +cabal-version: 1.18 name: alex -version: 3.5.3.0 +version: 3.5.4.0 -- don't forget updating changelog.md! license: BSD3 license-file: LICENSE @@ -23,7 +23,7 @@ build-type: Simple tested-with: GHC == 9.12.2 - GHC == 9.10.1 + GHC == 9.10.2 GHC == 9.8.4 GHC == 9.6.7 GHC == 9.4.8 @@ -42,9 +42,11 @@ data-files: AlexTemplate.hs AlexWrappers.hs -extra-source-files: +extra-doc-files: CHANGELOG.md README.md + +extra-source-files: examples/Makefile examples/Tokens.x examples/Tokens_gscan.x