From 4b959be0aecee64a778056263815c12d7eed275f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate=20Moonlight?= Date: Mon, 1 May 2023 21:30:06 +0200 Subject: [PATCH 1/6] Add a stock Ord instance for AlexPosn Close #233 --- src/ParseMonad.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParseMonad.hs b/src/ParseMonad.hs index f1c5f70..c64e6bf 100644 --- a/src/ParseMonad.hs +++ b/src/ParseMonad.hs @@ -64,7 +64,7 @@ alexGetByte (p,_,[],(c:s)) = let p' = alexMove p c -- assuming the usual eight character tab stops. data AlexPosn = AlexPn !Int !Int !Int - deriving (Eq,Show) + deriving (Eq, Show, Ord) alexStartPos :: AlexPosn alexStartPos = AlexPn 0 1 1 From 9ec6008f9a8c35540e76ed4b2c74aab6100e37e7 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 14 May 2023 19:23:20 +0200 Subject: [PATCH 2/6] Add changelog entry for `instance Ord AlexPosn` --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b69b4e0..ddf1990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Change in 3.3.0 + +* Add an `Ord` instance to `AlexPosn` (Issue [#233](https://github.com/haskell/alex/issues/233)). + +_Andreas Abel, 2023-05-14_ + ## Change in 3.2.7.4 * The user-supplied "epilogue" Haskell code is now put _last_ in the generated file. From 1fc061dce1148e1eb9c29e33eb7d63f79bb939a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate=20Moonlight?= Date: Sun, 14 May 2023 22:09:27 +0200 Subject: [PATCH 3/6] Add the instance to the template --- data/AlexWrappers.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/AlexWrappers.hs b/data/AlexWrappers.hs index 959ab89..955b27e 100644 --- a/data/AlexWrappers.hs +++ b/data/AlexWrappers.hs @@ -153,7 +153,7 @@ alexGetByte (AlexInput {alexStr=cs,alexBytePos=n}) = #if defined(ALEX_POSN) || defined(ALEX_MONAD) || defined(ALEX_POSN_BYTESTRING) || defined(ALEX_MONAD_BYTESTRING) || defined(ALEX_GSCAN) data AlexPosn = AlexPn !Int !Int !Int - deriving (Eq,Show) + deriving (Eq, Show, Ord) alexStartPos :: AlexPosn alexStartPos = AlexPn 0 1 1 From 73e4f7d735c9cf1e808e36c4642b5e49a87cb0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate=20Moonlight?= Date: Sun, 14 May 2023 22:33:16 +0200 Subject: [PATCH 4/6] Add .gitignore entries for dyn_hs and dyn_o --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 54fe16a..33e6017 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ *.prof *~ *.o +*.dyn_hi +*.dyn_o *.info /.ghc.environment.* /data/ From 7e8cfadd151f692df4035960e337192d15d62e9a Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 14 May 2023 19:38:37 +0200 Subject: [PATCH 5/6] Bump to 3.3.0 and finish changelog --- CHANGELOG.md | 3 ++- alex.cabal | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf1990..533798f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Change in 3.3.0 -* Add an `Ord` instance to `AlexPosn` (Issue [#233](https://github.com/haskell/alex/issues/233)). + * Add an `Ord` instance to `AlexPosn` (Issue [#233](https://github.com/haskell/alex/issues/233)). + * Tested with GHC 7.0 - 9.6.1. _Andreas Abel, 2023-05-14_ diff --git a/alex.cabal b/alex.cabal index 945e7a0..d84f811 100644 --- a/alex.cabal +++ b/alex.cabal @@ -1,6 +1,6 @@ cabal-version: >= 1.10 name: alex -version: 3.2.7.4 +version: 3.3.0 -- don't forget updating changelog.md! license: BSD3 license-file: LICENSE From 26c42b02789558c7e29dbe3e1b8f81ceca9561ac Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sun, 14 May 2023 19:45:09 +0200 Subject: [PATCH 6/6] Test that `instance Ord AlexPosn` is available --- tests/tokens_monad_bytestring.x | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tokens_monad_bytestring.x b/tests/tokens_monad_bytestring.x index 41179e1..b6c912a 100644 --- a/tests/tokens_monad_bytestring.x +++ b/tests/tokens_monad_bytestring.x @@ -36,7 +36,9 @@ data Token = Int AlexPosn Int | Err AlexPosn | EOF - deriving (Eq,Show) + deriving (Eq,Ord,Show) + -- Adding 'Ord' is possible since 3.3.0 (issue #233) + -- where an 'Ord' instance for 'AlexPosn' is generated by default. alexEOF = return EOF