Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AbstractFilePath #192

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a266326
Removed .ghci file
mmhat Jun 18, 2024
23afae1
Added hie.yaml
mmhat Jun 20, 2024
ad55906
Moved sources of validity-test to own directory
mmhat Jun 18, 2024
6e9ca25
Better use of IS_WINDOWS
mmhat Jun 18, 2024
7030cb8
Renamed the Foo type class to CheckInstantiated
mmhat Jun 20, 2024
1467bd3
Testsuite test: Moved TH stuff to own modules
mmhat Jun 20, 2024
e1b88b7
Testsuite test: Preliminary work to move more tests into the Common m…
mmhat Jun 20, 2024
79f0740
Testsuite test: Moved 'dirname' tests to Common modules
mmhat Jun 20, 2024
25f480e
Testsuite test: Moved 'filename' tests to Common modules
mmhat Jun 20, 2024
fa8c390
Testsuite test: Moved 'parent' tests to Common modules
mmhat Jun 20, 2024
fe559b9
Testsuite test: Moved 'splitDrive' tests to Common modules
mmhat Jun 20, 2024
16de840
Testsuite test: Moved 'isProperPrefixOf' tests to Common modules
mmhat Jun 20, 2024
d5b1bd1
Testsuite test: Moved 'stripProperPrefix' tests to Common modules
mmhat Jun 20, 2024
0fdb2e6
Testsuite test: Moved '</>' tests to Common modules
mmhat Jun 20, 2024
532ae73
Testsuite test: Moved some utilities to Common modules
mmhat Jun 20, 2024
9ef2340
Replicated source code to OsPath namespace
mmhat Jun 18, 2024
4db62ad
Adjusted version constraints and added os-string dependency
mmhat Jun 18, 2024
b5b8833
Use platform filepaths in OsPath.Internal modules
mmhat Jun 18, 2024
7a25335
Use platform filepaths in the OsPath modules of the public API
mmhat Jun 20, 2024
c04a187
Replicated test testsuite to test-ospath testsuite
mmhat Jun 20, 2024
588b90c
Use OsPath modules in test-ospath
mmhat Jun 20, 2024
b2a0cac
Moved normalization functions to Internal modules
mmhat Jun 20, 2024
1a527de
Moved validation functions to Internal modules
mmhat Jun 20, 2024
202529e
Replicated validity-test testsuite to validity-test-ospath testsuite
mmhat Jun 20, 2024
296930f
validity-test-ospath: Different modules for different platforms
mmhat Jun 20, 2024
f48c66e
Added orphan instance for OsPath paths to validity-test-ospath
mmhat Jun 20, 2024
5200bbd
Use OsPath modules in validity-test-ospath
mmhat Jun 20, 2024
8f2ba1c
Updated Stack configuration
mmhat Jun 21, 2024
d22abd4
Updated Stack configuration again
mmhat Jun 21, 2024
06dc7e4
Applied suggestions
mmhat Jun 24, 2024
3cf6556
Better documentation for FromJSON/ToJSON instances
mmhat Jun 25, 2024
55fe3bd
Better GenValid instance for PosixPath/WindowsPath
mmhat Jun 25, 2024
3f4c450
Moved aeson instances of OsPath to OsPath.Aeson namespace
mmhat Jun 25, 2024
e73559b
Provide newtype wrappers to control the decoding/encoding in OsPath a…
mmhat Jun 25, 2024
32c140e
Added Path.Internal.{Posix,Windows}.isWindows and removed some CPP fr…
mmhat Jun 25, 2024
5a16815
Added explicit conversion functions to OsPath.Aeson modules
mmhat Jun 26, 2024
db0807f
Removed Aeson instances for OsPath
mmhat Jul 14, 2024
9de73ab
Empty `Validity PLATFORM_PATH` instance
mmhat Jul 19, 2024
f8ded6a
Some small, final changes
Jul 29, 2024
179f6ef
Updated CI, tested-with and removed some dependencies
Jul 29, 2024
e2c1ec9
Support for filepath >=1.4.100.0 && <1.5
mmhat Jul 29, 2024
b2d8b95
Fixed Cabal conditionals, stack setup and HIE configuration
mmhat Jul 29, 2024
fe1eae9
Better compat sublibrary
mmhat Jul 30, 2024
3706145
Conditional filepath dependency for main library
mmhat Jul 30, 2024
56fb8cb
Added Stack configuration for +old-os-string
mmhat Jul 30, 2024
0fb94c9
Better backwards compatibility
mmhat Aug 9, 2024
1c000ee
Updated CI: Test Stack build with os-string flag
mmhat Aug 9, 2024
c105f76
Updated CI: Better cache keys
mmhat Aug 9, 2024
383ce37
Updated CI: Better naming of stack jobs
mmhat Aug 9, 2024
9b2bbe1
Updated CI: Use actions/cache@v4
mmhat Aug 9, 2024
7e1bf06
Removed extra-deps from stack.yaml
mmhat Aug 9, 2024
36a6cdf
Applied suggestions
mmhat Aug 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .ghci

This file was deleted.

17 changes: 8 additions & 9 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 Expand Up @@ -63,14 +62,14 @@ jobs:
# run: |
# cabal test path:validity-test

# As of 2023-10-16, the GitHub-hosted runner on ubuntu-latest comes with
# Stack 2.13.1 and GHC 9.6.3.
# As of 2024-07-29, the GitHub-hosted runner on ubuntu-latest comes with
# Stack 2.15.7 and GHC 9.10.1.
stack:
name: stack / ghc ${{ matrix.ghc }}
runs-on: ubuntu-latest
strategy:
matrix:
ghc: ["9.6.3"]
ghc: ["9.10.1"]

steps:
- name: Clone project
Expand Down
19 changes: 19 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cradle:
cabal:
- path: "src"
component: "lib:path"

- path: "compat"
component: "path:lib:compat"

- path: "test"
component: "path:test:test"

- path: "test-ospath"
component: "path:test:test-ospath"

- path: "validity-test"
component: "path:test:validity-test"

- path: "validity-test-ospath"
component: "path:test:validity-test-ospath"
131 changes: 131 additions & 0 deletions os-string-compat/System/OsString/Compat/Include.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
-- This template expects CPP definitions for:
-- PLATFORM_NAME = Posix | Windows
-- PLATFORM_STRING = PosixString | WindowsString
-- PLATFORM_CHAR = PosixChar | WindowsChar
-- IS_WINDOWS = 0 | 1

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StandaloneDeriving #-}

{-# OPTIONS_GHC -Wno-deprecations #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module System.OsString.Compat.PLATFORM_NAME
#if MIN_VERSION_os_string(2,0,0)
( PLATFORM_STRING(..)
, PLATFORM_CHAR(..)
, module OsString
)
#else
( PLATFORM_STRING(..)
, PLATFORM_CHAR(..)
, OsString.pstr
, 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 Data.Data (Data)
import System.OsString.Internal.Types (PLATFORM_STRING(..), PLATFORM_CHAR(..))
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

deriving instance Data PLATFORM_STRING

#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 os-string-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 os-string-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"
Loading
Loading