Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 6ac85cb

Browse files
committed
update pathy
1 parent 2e2cd7a commit 6ac85cb

3 files changed

Lines changed: 33 additions & 26 deletions

File tree

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"dependencies": {
1818
"purescript-prelude": "^3.1.0",
1919
"purescript-matryoshka": "^0.3.0",
20-
"purescript-pathy": "^4.0.0",
20+
"purescript-pathy": "safareli/purescript-pathy#refactor",
2121
"purescript-profunctor": "^3.2.0",
2222
"purescript-profunctor-lenses": "^3.2.0",
2323
"purescript-ejson": "^10.0.1",

src/SqlSquared/Path.purs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,51 @@ module SqlSquared.Path
1010
) where
1111

1212
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
13+
1714
import Control.Monad.Gen as Gen
1815
import Control.Monad.Rec.Class (class MonadRec)
16+
import Data.Either as E
17+
import Data.NonEmpty ((:|))
18+
import Pathy (posixParser, posixPrinter)
19+
import Pathy as Pt
20+
import Pathy.Gen as PtGen
1921
import SqlSquared.Utils ((∘))
2022

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+
type AnyDirPath = E.Either Pt.AbsDir Pt.RelDir
24+
type AnyFilePath = E.Either Pt.AbsFile Pt.RelFile
2325

2426
printAnyDirPath :: AnyDirPath -> String
25-
printAnyDirPath = E.either Pt.unsafePrintPath Pt.unsafePrintPath
27+
printAnyDirPath = E.either
28+
(Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter)
29+
(Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter)
2630

2731
parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDirPath
28-
parseAnyDirPath fail = Pt.parsePath
32+
parseAnyDirPath fail = Pt.parsePath posixParser
2933
(pure ∘ E.Right)
3034
(pure ∘ E.Left)
3135
(const $ fail "Expected a directory path")
3236
(const $ fail "Expected a directory path")
37+
(fail "Expected valid path")
3338

3439
printAnyFilePath :: AnyFilePath -> String
35-
printAnyFilePath = E.either Pt.unsafePrintPath Pt.unsafePrintPath
40+
printAnyFilePath = E.either
41+
(Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter)
42+
(Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter)
3643

3744
parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFilePath
38-
parseAnyFilePath fail = Pt.parsePath
45+
parseAnyFilePath fail = Pt.parsePath posixParser
3946
(const $ fail "Expected a file path")
4047
(const $ fail "Expected a file path")
4148
(pure ∘ E.Right)
4249
(pure ∘ E.Left)
50+
(fail "Expected valid path")
4351

4452
genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFilePath
4553
genAnyFilePath = Gen.oneOf
46-
$ (E.Left Pt.unsandbox <$> PtGen.genAbsFilePath)
47-
:| [E.Right Pt.unsandbox <$> PtGen.genRelFilePath]
54+
$ (E.Left <$> PtGen.genAbsFilePath)
55+
:| [E.Right <$> PtGen.genRelFilePath]
4856

4957
genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDirPath
5058
genAnyDirPath = Gen.oneOf
51-
$ (E.Left Pt.unsandbox <$> PtGen.genAbsDirPath)
52-
:| [E.Right Pt.unsandbox <$> PtGen.genRelDirPath]
59+
$ (E.Left <$> PtGen.genAbsDirPath)
60+
:| [E.Right <$> PtGen.genRelDirPath]

test/src/Constructors.purs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ module Test.Constructors where
22

33
import Prelude
44

5-
import Data.List as L
5+
import Data.Either as E
66
import Data.Lens ((.~), (<>~), (?~))
7+
import Data.List as L
78
import Data.Maybe (Maybe(..))
89
import Data.NonEmpty as NE
9-
import Data.Either as E
10-
import Data.Path.Pathy as Pt
11-
10+
import Data.Symbol (SProxy(..))
11+
import Pathy as Pt
1212
import SqlSquared as S
1313
import SqlSquared.Utils ((×), (∘))
14-
1514
import Test.Unit (suite, test, TestSuite)
1615
import Test.Unit.Assert as Assert
1716

@@ -26,9 +25,9 @@ selectQuery =
2625
{ alias: Nothing
2726
, path: E.Left
2827
$ Pt.rootDir
29-
Pt.</> Pt.dir "mongo"
30-
Pt.</> Pt.dir "testDb"
31-
Pt.</> Pt.file "patients"
28+
Pt.</> Pt.dir (SProxy :: SProxy "mongo")
29+
Pt.</> Pt.dir (SProxy :: SProxy "testDb")
30+
Pt.</> Pt.file (SProxy :: SProxy "patients")
3231
})
3332
( Just $ S.binop S.Eq (S.ident "quux") (S.num 12.0) )
3433
( Just $ S.groupBy [ S.ident "zzz" ] # S.having ( S.binop S.Gt (S.ident "ooo") ( S.int 2)) )
@@ -53,9 +52,9 @@ buildSelectQuery =
5352
{ alias: Nothing
5453
, path: E.Left
5554
$ Pt.rootDir
56-
Pt.</> Pt.dir "mongo"
57-
Pt.</> Pt.dir "testDb"
58-
Pt.</> Pt.file "patients"
55+
Pt.</> Pt.dir (SProxy :: SProxy "mongo")
56+
Pt.</> Pt.dir (SProxy :: SProxy "testDb")
57+
Pt.</> Pt.file (SProxy :: SProxy "patients")
5958
}))
6059

6160
∘ (S._filter ?~ S.binop S.Eq (S.ident "quux") (S.num 12.0))

0 commit comments

Comments
 (0)