Skip to content

Commit

Permalink
Support for filepath >=1.4.100.0 && <1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mmhat committed Jul 29, 2024
1 parent 179f6ef commit e2c1ec9
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 97 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["3.10"]
cabal: ["3.12"]
ghc:
# GHC versions listed as current stable releases
- "9.2.8"
- "9.4.7"
- "9.6.3"
# GHC 9.8 only works with cabal-install >= 3.10.2.0, which is not
# available from haskell-actions/setup (or on Hackage)
# - "9.8.1"
- "9.4.8"
- "9.6.6"
- "9.8.2"
- "9.10.1"

steps:
- uses: actions/checkout@v4
Expand Down
137 changes: 137 additions & 0 deletions compat/System/OsString/Compat/Include.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
-- This template expects CPP definitions for:
-- PLATFORM_NAME = Posix | Windows
-- PLATFORM_STRING = PosixString | WindowsString
-- PLATFORM_CHAR = PosixChar | WindowsChar
-- IS_WINDOWS = 0 | 1

{-# OPTIONS_GHC -Wno-deprecations #-}

module System.OsString.Compat.PLATFORM_NAME
#if MIN_VERSION_os_string(2,0,0)
( OsString.all
, OsString.any
, OsString.break
, OsString.breakEnd
, OsString.dropWhileEnd
, OsString.empty
, OsString.init
, OsString.isInfixOf
, OsString.isPrefixOf
, OsString.isSuffixOf
, OsString.length
, OsString.map
, OsString.null
, OsString.replicate
, OsString.singleton
, OsString.span
, OsString.spanEnd
, OsString.stripPrefix
, OsString.uncons
)
#else
( System.OsString.Compat.PLATFORM_NAME.all
, System.OsString.Compat.PLATFORM_NAME.any
, System.OsString.Compat.PLATFORM_NAME.break
, System.OsString.Compat.PLATFORM_NAME.breakEnd
, System.OsString.Compat.PLATFORM_NAME.dropWhileEnd
, System.OsString.Compat.PLATFORM_NAME.empty
, System.OsString.Compat.PLATFORM_NAME.init
, System.OsString.Compat.PLATFORM_NAME.isInfixOf
, System.OsString.Compat.PLATFORM_NAME.isPrefixOf
, System.OsString.Compat.PLATFORM_NAME.isSuffixOf
, System.OsString.Compat.PLATFORM_NAME.length
, System.OsString.Compat.PLATFORM_NAME.map
, System.OsString.Compat.PLATFORM_NAME.null
, System.OsString.Compat.PLATFORM_NAME.replicate
, System.OsString.Compat.PLATFORM_NAME.singleton
, System.OsString.Compat.PLATFORM_NAME.span
, System.OsString.Compat.PLATFORM_NAME.spanEnd
, System.OsString.Compat.PLATFORM_NAME.stripPrefix
, System.OsString.Compat.PLATFORM_NAME.uncons
)
#endif
where

import System.OsString.Internal.Types (PLATFORM_STRING(..), PLATFORM_CHAR(..))

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / macOS-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.2.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.4.8

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.6.6

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.8.2

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant

Check warning on line 55 in compat/System/OsString/Compat/Include.hs

View workflow job for this annotation

GitHub Actions / windows-latest / ghc 9.10.1

The import of ‘System.OsString.Internal.Types’ is redundant
import System.OsString.PLATFORM_NAME as OsString

#if !MIN_VERSION_os_string(2,0,0)
import Data.Coerce (coerce)

#if IS_WINDOWS
import qualified System.OsPath.Data.ByteString.Short.Word16 as BSP
#else
import qualified System.OsPath.Data.ByteString.Short as BSP
#endif
#endif

#if !MIN_VERSION_os_string(2,0,0)
all :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> Bool
all = coerce BSP.all

any :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> Bool
any = coerce BSP.any

break
:: (PLATFORM_CHAR -> Bool)
-> PLATFORM_STRING
-> (PLATFORM_STRING, PLATFORM_STRING)
break = coerce BSP.break

breakEnd
:: (PLATFORM_CHAR -> Bool)
-> PLATFORM_STRING
-> (PLATFORM_STRING, PLATFORM_STRING)
breakEnd = coerce BSP.breakEnd

dropWhileEnd :: (PLATFORM_CHAR -> Bool) -> PLATFORM_STRING -> PLATFORM_STRING
dropWhileEnd = coerce BSP.dropWhileEnd

empty :: PLATFORM_STRING
empty = coerce BSP.empty

init :: PLATFORM_STRING -> PLATFORM_STRING
init = coerce BSP.init

isInfixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isInfixOf = coerce BSP.isInfixOf

isPrefixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isPrefixOf = coerce BSP.isPrefixOf

isSuffixOf :: PLATFORM_STRING -> PLATFORM_STRING -> Bool
isSuffixOf = coerce BSP.isSuffixOf

length :: PLATFORM_STRING -> Int
length = coerce BSP.length

map :: (PLATFORM_CHAR -> PLATFORM_CHAR) -> PLATFORM_STRING -> PLATFORM_STRING
map = coerce BSP.map

null :: PLATFORM_STRING -> Bool
null = coerce BSP.null

replicate :: Int -> PLATFORM_CHAR -> PLATFORM_STRING
replicate = coerce BSP.replicate

singleton :: PLATFORM_CHAR -> PLATFORM_STRING
singleton = coerce BSP.singleton

span
:: (PLATFORM_CHAR -> Bool)
-> PLATFORM_STRING
-> (PLATFORM_STRING, PLATFORM_STRING)
span = coerce BSP.span

spanEnd
:: (PLATFORM_CHAR -> Bool)
-> PLATFORM_STRING
-> (PLATFORM_STRING, PLATFORM_STRING)
spanEnd = coerce BSP.spanEnd

stripPrefix :: PLATFORM_STRING -> PLATFORM_STRING -> Maybe PLATFORM_STRING
stripPrefix = coerce BSP.stripPrefix

uncons :: PLATFORM_STRING -> Maybe (PLATFORM_CHAR, PLATFORM_STRING)
uncons = coerce BSP.uncons
#endif
6 changes: 6 additions & 0 deletions compat/System/OsString/Compat/Posix.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{-# LANGUAGE CPP #-}
#define PLATFORM_NAME Posix
#define PLATFORM_STRING PosixString
#define PLATFORM_CHAR PosixChar
#define IS_WINDOWS 0
#include "Include.hs"
6 changes: 6 additions & 0 deletions compat/System/OsString/Compat/Windows.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{-# LANGUAGE CPP #-}
#define PLATFORM_NAME Windows
#define PLATFORM_STRING WindowsString
#define PLATFORM_CHAR WindowsChar
#define IS_WINDOWS 1
#include "Include.hs"
113 changes: 82 additions & 31 deletions path.cabal
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cabal-version: 1.18
cabal-version: 3.0
name: path
version: 0.9.5
synopsis: Support for well-typed paths
description: Support for well-typed paths.
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
author: Chris Done <[email protected]>
maintainer: Chris Done <[email protected]>
Expand All @@ -17,6 +17,7 @@ extra-source-files: README.md
, src/Path/Internal/Include.hs
, src/OsPath/Include.hs
, src/OsPath/Internal/Include.hs
, src/System/OsString/Compat/Include.hs
, test/Common/Include.hs
, test-ospath/Common/Include.hs
, validity-test-ospath/Include.hs
Expand All @@ -27,8 +28,34 @@ flag dev
manual: True
default: False

flag old-os-string
description: Use an older version of the os-string library.
manual: False
default: False

common language
ghc-options: -Wall

if flag(dev)
ghc-options: -Wcompat
-Werror
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wnoncanonical-monad-instances

default-language: Haskell2010

common rts
ghc-options: -O2
-threaded
-rtsopts
-with-rtsopts=-N

library
import: language

hs-source-dirs: src

exposed-modules: Path
, Path.Posix
, Path.Windows
Expand All @@ -41,36 +68,57 @@ library
, OsPath.Internal
, OsPath.Internal.Posix
, OsPath.Internal.Windows

build-depends: aeson >= 1.0.0.0
, base >= 4.12 && < 5
, deepseq
, exceptions >= 0.4 && < 0.11
, filepath >= 1.5.0.0
, hashable >= 1.2 && < 1.5
, os-string >= 2.0.0
, path:compat
, text
, template-haskell
if flag(dev)
ghc-options: -Wall -Werror

if flag(old-os-string)
build-depends: filepath >= 1.5.0.0
, os-string >= 2.0.0
else
ghc-options: -O2 -Wall
if flag(dev)
ghc-options: -Wcompat
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wnoncanonical-monad-instances
default-language: Haskell2010
build-depends: filepath >= 1.4.100.0
, os-string < 2.0.0

library compat
import: language

hs-source-dirs: compat
visibility: private

exposed-modules: System.OsString.Compat.Posix
, System.OsString.Compat.Windows

build-depends: base >= 4.12 && < 5

if flag(old-os-string)
build-depends: filepath >= 1.5.0.0
, os-string >= 2.0.0
else
build-depends: filepath >= 1.4.100.0
, os-string < 2.0.0

test-suite test
import: language
import: rts

type: exitcode-stdio-1.0
main-is: Main.hs

hs-source-dirs: test

other-modules: Posix
, Windows
, Common.Posix
, Common.Windows
, TH.Posix
, TH.Windows
hs-source-dirs: test

build-depends: aeson
, base
, bytestring
Expand All @@ -79,58 +127,62 @@ test-suite test
, hspec >= 2.0 && < 3
, path
, template-haskell
if flag(dev)
ghc-options: -Wall -Werror
else
ghc-options: -O2 -Wall
default-language: Haskell2010

test-suite test-ospath
import: language
import: rts

type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: test-ospath

other-modules: Posix
, Windows
, Common.Posix
, Common.Windows
, TH.Posix
, TH.Windows
hs-source-dirs: test-ospath

build-depends: base
, exceptions
, filepath
, hspec >= 2.0 && < 3
, os-string
, path
, path:compat
, template-haskell
if flag(dev)
ghc-options: -Wall -Werror
else
ghc-options: -O2 -Wall
default-language: Haskell2010

test-suite validity-test
import: language
import: rts

type: exitcode-stdio-1.0
main-is: Main.hs
other-modules: Path.Gen
hs-source-dirs: validity-test

other-modules: Path.Gen

build-depends: QuickCheck
, base
, filepath
, genvalidity >= 1.0
, genvalidity-hspec >= 0.7
, hspec >= 2.0 && < 3
, path
default-language: Haskell2010
ghc-options: -threaded -rtsopts -with-rtsopts=-N

test-suite validity-test-ospath
import: language
import: rts

type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: validity-test-ospath

other-modules: OsPath.Gen.Posix
, OsPath.Gen.Windows
, Posix
, Windows
hs-source-dirs: validity-test-ospath

build-depends: QuickCheck
, base
, filepath
Expand All @@ -139,9 +191,8 @@ test-suite validity-test-ospath
, hspec >= 2.0 && < 3
, os-string
, path
, path:compat
, validity-bytestring >=0.4.1.0
default-language: Haskell2010
ghc-options: -threaded -rtsopts -with-rtsopts=-N

source-repository head
type: git
Expand Down
Loading

0 comments on commit e2c1ec9

Please sign in to comment.