Skip to content

Commit

Permalink
Merge branch 'drop-older-env'
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai committed Mar 17, 2024
2 parents b2ded1a + a2e0b54 commit 58d52c9
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 104 deletions.
23 changes: 2 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,28 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ['8.0.2', '8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.8', '9.4.8', '9.6.4']
ghc: ['8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.8', '9.4.8', '9.6.4']
os: [ubuntu-latest]
include:
- ghc: '8.0.2'
stack: '2.13' # Due to a bug, Stack 2.15.1 did not support versions of GHC before 8.2.
resolver: 'lts-9.21'
flags: ''
- ghc: '8.2.2'
stack: 'latest'
resolver: 'lts-11.22'
flags: ''
- ghc: '8.4.4'
stack: 'latest'
resolver: 'lts-12.26'
flags: ''
- ghc: '8.6.5'
stack: 'latest'
resolver: 'lts-14.27'
flags: ''
- ghc: '8.8.4'
stack: 'latest'
resolver: 'lts-16.31'
flags: ''
- ghc: '8.10.7'
stack: 'latest'
resolver: 'lts-18.28'
flags: ''
- ghc: '9.0.2'
stack: 'latest'
resolver: 'lts-19.33'
flags: ''
- ghc: '9.2.8'
stack: 'latest'
resolver: 'lts-20.26'
flags: ''
- ghc: '9.4.8'
stack: 'latest'
resolver: 'lts-21.25'
flags: ''
- ghc: '9.6.4'
stack: 'latest'
resolver: 'lts-22.13'
coveralls: true
flags: '--coverage'
Expand All @@ -59,7 +40,7 @@ jobs:
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: ${{ matrix.stack }}
stack-version: latest

- uses: actions/cache@v1
name: Cache ~/.stack
Expand Down
17 changes: 8 additions & 9 deletions pseudo-boolean.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ library
FlexibleContexts
OverloadedStrings
build-depends:
base >=4.6.0.1 && <4.20,
containers >=0.4.2.1,
base >=4.12.0.0 && <4.20,
containers >=0.6.0.1,
parsec >=3.1.2 && <4,
megaparsec >=4 && <10,
bytestring >=0.9.2.1 && <0.13,
bytestring-builder,
dlist >=0.7.0 && <1.1.0,
attoparsec >=0.10.4.0,
deepseq >=1.3.0.0,
hashable >=1.1.2.5 && <1.5.0.0,
megaparsec >=7 && <10,
bytestring >=0.10.8.2 && <0.13,
dlist >=0.8.0.5 && <1.1.0,
attoparsec >=0.13.2.2,
deepseq >=1.4.4.0,
hashable >=1.2.7.0 && <1.5.0.0,
void
hs-source-dirs: src
default-language: Haskell2010
Expand Down
2 changes: 1 addition & 1 deletion src/Data/PseudoBoolean/Attoparsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module Data.PseudoBoolean.Attoparsec
) where

import Prelude hiding (sum)
import Control.Applicative ((<|>), (<*))
import Control.Applicative ((<|>))
import Control.Monad
import Data.Attoparsec.ByteString.Char8 hiding (isDigit)
import qualified Data.Attoparsec.ByteString.Lazy as L
Expand Down
1 change: 0 additions & 1 deletion src/Data/PseudoBoolean/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import qualified Data.DList as DList
import qualified Data.IntSet as IntSet
import qualified Data.Set as Set
import Data.List (sortBy)
import Data.Monoid hiding (Sum (..))
import Data.Ord
import Data.String
import Text.Printf
Expand Down
1 change: 0 additions & 1 deletion src/Data/PseudoBoolean/ByteStringBuilder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import Prelude hiding (sum)
import qualified Data.IntSet as IntSet
import qualified Data.Set as Set
import Data.List (sortBy)
import Data.Monoid hiding (Sum (..))
import qualified Data.ByteString.Lazy as BS
import Data.ByteString.Builder (Builder, intDec, integerDec, char7, string7, hPutBuilder, toLazyByteString)
import Data.Ord
Expand Down
5 changes: 0 additions & 5 deletions src/Data/PseudoBoolean/Internal/TextUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ readUnsignedInteger str = assert (result == read str) $ result
result = go 0 str

lim :: Word
#if !MIN_VERSION_base(4,6,1) && WORD_SIZE_IN_BITS == 32
{- To avoid a bug of maxBound <https://ghc.haskell.org/trac/ghc/ticket/8072> -}
lim = 0xFFFFFFFF `div` 10
#else
lim = maxBound `div` 10
#endif

go :: Integer -> [Char] -> Integer
go !r [] = r
Expand Down
64 changes: 1 addition & 63 deletions src/Data/PseudoBoolean/Megaparsec.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE BangPatterns, FlexibleContexts, TypeFamilies, CPP, ConstraintKinds #-}
{-# LANGUAGE BangPatterns, FlexibleContexts, TypeFamilies, ConstraintKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
Expand Down Expand Up @@ -40,75 +40,33 @@ module Data.PseudoBoolean.Megaparsec
) where

import Prelude hiding (sum)
import Control.Applicative ((<*))
import Control.Monad
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Maybe
#if MIN_VERSION_megaparsec(6,0,0)
import Data.String
import Data.Word
import Data.Void
#endif
import Text.Megaparsec hiding (ParseError)
import qualified Text.Megaparsec as MP
#if MIN_VERSION_megaparsec(6,0,0)
import Text.Megaparsec.Byte
#else
import Text.Megaparsec.Prim (MonadParsec ())
#endif
import Data.PseudoBoolean.Types
import Data.PseudoBoolean.Internal.TextUtil

#if MIN_VERSION_megaparsec(6,0,0)

type C e s m = (MonadParsec e s m, Token s ~ Word8, IsString (Tokens s))

char8 :: C e s m => Char -> m Word8
char8 = char . fromIntegral . fromEnum

#else

#if MIN_VERSION_megaparsec(5,0,0)
type C e s m = (MonadParsec e s m, Token s ~ Char)
#elif MIN_VERSION_megaparsec(4,4,0)
type C e s m = (MonadParsec s m Char)
#else
type C e s m = (MonadParsec s m Char, MonadPlus m)
#endif

char8 :: C e s m => Char -> m Char
char8 = char

#endif

#if MIN_VERSION_megaparsec(7,0,0)
anyChar :: C e s m => m Word8
anyChar = anySingle
#endif

-- | Parser for OPB files
#if MIN_VERSION_megaparsec(6,0,0)
opbParser :: (MonadParsec e s m, Token s ~ Word8, IsString (Tokens s)) => m Formula
#elif MIN_VERSION_megaparsec(5,0,0)
opbParser :: (MonadParsec e s m, Token s ~ Char) => m Formula
#elif MIN_VERSION_megaparsec(4,4,0)
opbParser :: (MonadParsec s m Char) => m Formula
#else
opbParser :: (MonadParsec s m Char, MonadPlus m) => m Formula
#endif
opbParser = formula

-- | Parser for WBO files
#if MIN_VERSION_megaparsec(6,0,0)
wboParser :: (MonadParsec e s m, Token s ~ Word8, IsString (Tokens s)) => m SoftFormula
#elif MIN_VERSION_megaparsec(5,0,0)
wboParser :: (MonadParsec e s m, Token s ~ Char) => m SoftFormula
#elif MIN_VERSION_megaparsec(4,4,0)
wboParser :: (MonadParsec s m Char) => m SoftFormula
#else
wboParser :: (MonadParsec s m Char, MonadPlus m) => m SoftFormula
#endif
wboParser = softformula

-- <formula>::= <sequence_of_comments> [<objective>] <sequence_of_comments_or_constraints>
Expand Down Expand Up @@ -208,11 +166,7 @@ integer = msum
unsigned_integer :: C e s m => m Integer
unsigned_integer = do
ds <- some digitChar
#if MIN_VERSION_megaparsec(6,0,0)
return $! readUnsignedInteger (map (toEnum . fromIntegral) ds)
#else
return $! readUnsignedInteger ds
#endif

-- <relational_operator>::= ">=" | "="
relational_operator :: C e s m => m Op
Expand Down Expand Up @@ -262,23 +216,11 @@ oneOrMoreLiterals = do
literal :: C e s m => m Lit
literal = variablename <|> (char8 '~' >> liftM negate variablename)

#if MIN_VERSION_megaparsec(7,0,0)
type ParseError = MP.ParseErrorBundle BL.ByteString Void
#elif MIN_VERSION_megaparsec(6,0,0)
type ParseError = MP.ParseError Word8 Void
#elif MIN_VERSION_megaparsec(5,0,0)
type ParseError = MP.ParseError Char Dec
#else
type ParseError = MP.ParseError
#endif

-- | Parse a OPB format string containing pseudo boolean problem.
parseOPBString :: String -> String -> Either ParseError Formula
#if MIN_VERSION_megaparsec(6,0,0)
parseOPBString info s = parse (formula <* eof) info (BL.pack s)
#else
parseOPBString = parse (formula <* eof)
#endif

-- | Parse a OPB format lazy bytestring containing pseudo boolean problem.
parseOPBByteString :: String -> ByteString -> Either ParseError Formula
Expand Down Expand Up @@ -341,11 +283,7 @@ softconstraint = do

-- | Parse a WBO format string containing weighted boolean optimization problem.
parseWBOString :: String -> String -> Either ParseError SoftFormula
#if MIN_VERSION_megaparsec(6,0,0)
parseWBOString info s = parse (softformula <* eof) info (BL.pack s)
#else
parseWBOString = parse (softformula <* eof)
#endif

-- | Parse a WBO format lazy bytestring containing pseudo boolean problem.
parseWBOByteString :: String -> ByteString -> Either ParseError SoftFormula
Expand Down
1 change: 0 additions & 1 deletion src/Data/PseudoBoolean/Parsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module Data.PseudoBoolean.Parsec
) where

import Prelude hiding (sum)
import Control.Applicative ((<*))
import Control.Monad
import Data.ByteString.Lazy (ByteString)
import Data.Maybe
Expand Down
2 changes: 0 additions & 2 deletions test/TestPBFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
{-# OPTIONS_GHC -Wall #-}
module Main (main) where

import Data.Either
import qualified Data.ByteString.Lazy.Char8 as BSChar8
import System.IO
import System.IO.Temp
import Test.Tasty
import Test.Tasty.QuickCheck
import Test.Tasty.HUnit
import Test.Tasty.TH
Expand Down

0 comments on commit 58d52c9

Please sign in to comment.