|
1 | 1 | module SqlSquared.Path
|
2 |
| - ( AnyFilePath |
3 |
| - , AnyDirPath |
4 |
| - , parseAnyFilePath |
| 2 | + ( parseAnyFilePath |
5 | 3 | , printAnyFilePath
|
6 | 4 | , parseAnyDirPath
|
7 | 5 | , printAnyDirPath
|
8 | 6 | , genAnyFilePath
|
9 | 7 | , genAnyDirPath
|
| 8 | + , module PathyTypeReexprts |
10 | 9 | ) where
|
11 | 10 |
|
12 | 11 | import Prelude
|
13 |
| -import Data.Either as E |
14 |
| -import Data.NonEmpty ((:|)) |
15 |
| -import Data.Path.Pathy as Pt |
16 |
| -import Data.Path.Pathy.Gen as PtGen |
| 12 | + |
17 | 13 | import Control.Monad.Gen as Gen
|
18 | 14 | import Control.Monad.Rec.Class (class MonadRec)
|
| 15 | +import Data.Either as E |
| 16 | +import Data.NonEmpty ((:|)) |
| 17 | +import Pathy as Pt |
| 18 | +import Pathy (AnyDir, AnyFile) as PathyTypeReexprts |
| 19 | +import Pathy (AnyDir, AnyFile) |
| 20 | +import Pathy.Gen as PtGen |
19 | 21 | import SqlSquared.Utils ((∘))
|
20 | 22 |
|
21 |
| -type AnyDirPath = E.Either (Pt.AbsDir Pt.Unsandboxed) (Pt.RelDir Pt.Unsandboxed) |
22 |
| -type AnyFilePath = E.Either (Pt.AbsFile Pt.Unsandboxed) (Pt.RelFile Pt.Unsandboxed) |
23 | 23 |
|
24 |
| -printAnyDirPath :: AnyDirPath -> String |
25 |
| -printAnyDirPath = E.either Pt.unsafePrintPath Pt.unsafePrintPath |
| 24 | +printAnyDirPath :: AnyDir -> String |
| 25 | +printAnyDirPath = E.either |
| 26 | + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) |
| 27 | + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) |
26 | 28 |
|
27 |
| -parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDirPath |
28 |
| -parseAnyDirPath fail = Pt.parsePath |
| 29 | +parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDir |
| 30 | +parseAnyDirPath fail = Pt.parsePath Pt.posixParser |
29 | 31 | (pure ∘ E.Right)
|
30 | 32 | (pure ∘ E.Left)
|
31 | 33 | (const $ fail "Expected a directory path")
|
32 | 34 | (const $ fail "Expected a directory path")
|
| 35 | + (fail "Expected valid path") |
33 | 36 |
|
34 |
| -printAnyFilePath :: AnyFilePath -> String |
35 |
| -printAnyFilePath = E.either Pt.unsafePrintPath Pt.unsafePrintPath |
| 37 | +printAnyFilePath :: AnyFile -> String |
| 38 | +printAnyFilePath = E.either |
| 39 | + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) |
| 40 | + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) |
36 | 41 |
|
37 |
| -parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFilePath |
38 |
| -parseAnyFilePath fail = Pt.parsePath |
| 42 | +parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFile |
| 43 | +parseAnyFilePath fail = Pt.parsePath Pt.posixParser |
39 | 44 | (const $ fail "Expected a file path")
|
40 | 45 | (const $ fail "Expected a file path")
|
41 | 46 | (pure ∘ E.Right)
|
42 | 47 | (pure ∘ E.Left)
|
| 48 | + (fail "Expected valid path") |
43 | 49 |
|
44 |
| -genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFilePath |
| 50 | +genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFile |
45 | 51 | genAnyFilePath = Gen.oneOf
|
46 |
| - $ (E.Left ∘ Pt.unsandbox <$> PtGen.genAbsFilePath) |
47 |
| - :| [E.Right ∘ Pt.unsandbox <$> PtGen.genRelFilePath] |
| 52 | + $ (E.Left <$> PtGen.genAbsFilePath) |
| 53 | + :| [E.Right <$> PtGen.genRelFilePath] |
48 | 54 |
|
49 |
| -genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDirPath |
| 55 | +genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDir |
50 | 56 | genAnyDirPath = Gen.oneOf
|
51 |
| - $ (E.Left ∘ Pt.unsandbox <$> PtGen.genAbsDirPath) |
52 |
| - :| [E.Right ∘ Pt.unsandbox <$> PtGen.genRelDirPath] |
| 57 | + $ (E.Left <$> PtGen.genAbsDirPath) |
| 58 | + :| [E.Right <$> PtGen.genRelDirPath] |
0 commit comments