Skip to content

Commit

Permalink
Updated for GHC v9.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelBoucey committed Nov 8, 2023
1 parent 468b85b commit acafeeb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 71 deletions.
82 changes: 20 additions & 62 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.16.5
# version: 0.17.20231106
#
# REGENDATA ("0.16.5",["github","IPv6Addr.cabal"])
# REGENDATA ("0.17.20231106",["github","IPv6Addr.cabal"])
#
name: Haskell-CI
on:
Expand All @@ -33,14 +33,14 @@ jobs:
compilerVersion: 9.6.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.5
- compiler: ghc-9.4.7
compilerKind: ghc
compilerVersion: 9.4.5
compilerVersion: 9.4.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.6
- compiler: ghc-9.2.8
compilerKind: ghc
compilerVersion: 9.2.6
compilerVersion: 9.2.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand All @@ -53,52 +53,17 @@ jobs:
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.0.2
compilerKind: ghc
compilerVersion: 8.0.2
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -110,20 +75,13 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -204,8 +162,8 @@ jobs:
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_IPv6Addr}" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package IPv6Addr" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
echo "package IPv6Addr" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(IPv6Addr)$/; }' >> cabal.project.local
Expand Down
8 changes: 4 additions & 4 deletions IPv6Addr.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: IPv6Addr
version: 2.0.5.1
version: 2.0.6
synopsis: Library to deal with IPv6 address text representations.
description: Library to deal with IPv6 address text representations, canonization and manipulations.
homepage: https://github.com/MichelBoucey/IPv6Addr
Expand All @@ -13,7 +13,7 @@ build-type: Simple
extra-source-files: README.md
cabal-version: >=1.10

Tested-With: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.5 || ==9.6.2
Tested-With: GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.7 || ==9.6.1

Source-Repository head
Type: git
Expand All @@ -23,12 +23,12 @@ library
exposed-modules: Text.IPv6Addr
other-extensions: OverloadedStrings
build-depends: base >=4.8 && < 5
, text >=1.1 && < 1.3 || == 2.0.*
, text >=1.1 && < 1.3 || >=2.0 && <2.2
, iproute >=1.3 && < 1.8
, network >=2.5 && < 4
, random >=1.0 && < 1.3
, attoparsec >=0.12 && < 0.15
, aeson >= 0.8.0.2 && < 1.6 || >= 2.0 && < 2.3
, aeson >=0.8.0.2 && < 1.6 || >= 2.0 && < 2.3
, network-info >=0.2 && <=0.3
default-language: Haskell2010
GHC-Options: -Wall
Expand Down
17 changes: 12 additions & 5 deletions Text/IPv6Addr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Data.Attoparsec.Text
import Data.Char (intToDigit, isDigit)
import Data.IP (IPv6)
import Data.List (elemIndex, elemIndices, foldl', group,
intersperse, isSuffixOf)
intersperse, isSuffixOf, uncons)
import Data.Maybe (fromJust, isJust)

#if !MIN_VERSION_base(4,11,0)
Expand Down Expand Up @@ -328,7 +328,7 @@ isIPv6Addr tks =
diffNext [] = False
diffNext [_] = True
diffNext (t:ts) = do
let h = head ts
let h = justHead ts
case t of
DoubleColon ->
case h of
Expand All @@ -346,7 +346,7 @@ isIPv6Addr tks =
_ -> diffNext ts
_ -> diffNext ts
firstValidToken l =
case head l of
case justHead l of
SixteenBit _ -> True
DoubleColon -> True
AllZeros -> True
Expand Down Expand Up @@ -463,7 +463,7 @@ fromDoubleColon tks =
else do
let s = splitAt (fromJust $ elemIndex DoubleColon tks) tks
fsts = fst s
snds = if not (null (snd s)) then tail(snd s) else []
snds = if not (null (snd s)) then justTail(snd s) else []
fste = if null fsts then [] else fsts <> [Colon]
snde = if null snds then [] else Colon : snds
fste <> allZerosTokensReplacement(quantityOfAllZerosTokenToReplace tks) <> snde
Expand Down Expand Up @@ -500,7 +500,7 @@ toDoubleColon tks =
zerosRunsList x =
helper <$> groupZerosRuns x
where
helper h = (head h == AllZeros, lh) where lh = length h
helper h = (justHead h == AllZeros, lh) where lh = length h
groupZerosRuns = group . filter (/= Colon)

ipv6TokensToIPv6Addr :: [IPv6AddrToken] -> Maybe IPv6Addr
Expand Down Expand Up @@ -570,3 +570,10 @@ ipv6AddrFullChunk = count 4 hexaChar
hexaChar :: Parser Char
hexaChar = satisfy (inClass "0-9a-fA-F")

-- Helper functions
justHead :: [a] -> a
justHead l = fst (fromJust $ uncons l)

justTail :: [a] -> [a]
justTail l = snd (fromJust $ uncons l)

0 comments on commit acafeeb

Please sign in to comment.