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

Commit 34d6fd9

Browse files
authored
Merge pull request #44 from safareli/pathy
update pathy
2 parents 2e2cd7a + 422a2c8 commit 34d6fd9

File tree

5 files changed

+42
-37
lines changed

5 files changed

+42
-37
lines changed

bower.json

+1-1
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": "^5.0.0",
2121
"purescript-profunctor": "^3.2.0",
2222
"purescript-profunctor-lenses": "^3.2.0",
2323
"purescript-ejson": "^10.0.1",

src/SqlSquared/Path.purs

+29-23
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
module SqlSquared.Path
2-
( AnyFilePath
3-
, AnyDirPath
4-
, parseAnyFilePath
2+
( parseAnyFilePath
53
, printAnyFilePath
64
, parseAnyDirPath
75
, printAnyDirPath
86
, genAnyFilePath
97
, genAnyDirPath
8+
, module PathyTypeReexprts
109
) where
1110

1211
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+
1713
import Control.Monad.Gen as Gen
1814
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
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)
2323

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)
2628

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
2931
(pure ∘ E.Right)
3032
(pure ∘ E.Left)
3133
(const $ fail "Expected a directory path")
3234
(const $ fail "Expected a directory path")
35+
(fail "Expected valid path")
3336

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)
3641

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
3944
(const $ fail "Expected a file path")
4045
(const $ fail "Expected a file path")
4146
(pure ∘ E.Right)
4247
(pure ∘ E.Left)
48+
(fail "Expected valid path")
4349

44-
genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFilePath
50+
genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFile
4551
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]
4854

49-
genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDirPath
55+
genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDir
5056
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]

src/SqlSquared/Signature.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ data SqlF literal a
140140
| Parens a
141141

142142
data SqlDeclF a
143-
= Import Pt.AnyDirPath
143+
= Import Pt.AnyDir
144144
| FunctionDecl (FunctionDeclR a)
145145

146146
newtype SqlModuleF a =

src/SqlSquared/Signature/Relation.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type VariRelR =
3636
}
3737

3838
type TableRelR =
39-
{ path Pt.AnyFilePath
39+
{ path Pt.AnyFile
4040
, alias Maybe String
4141
}
4242

test/src/Constructors.purs

+10-11
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)