From 6ac85cba58925ae14f801ecff46af85a7743bb3f Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Fri, 23 Feb 2018 21:26:22 +0400 Subject: [PATCH 1/3] update pathy --- bower.json | 2 +- src/SqlSquared/Path.purs | 36 ++++++++++++++++++++++-------------- test/src/Constructors.purs | 21 ++++++++++----------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/bower.json b/bower.json index 66a932b..f6e1ffa 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,7 @@ "dependencies": { "purescript-prelude": "^3.1.0", "purescript-matryoshka": "^0.3.0", - "purescript-pathy": "^4.0.0", + "purescript-pathy": "safareli/purescript-pathy#refactor", "purescript-profunctor": "^3.2.0", "purescript-profunctor-lenses": "^3.2.0", "purescript-ejson": "^10.0.1", diff --git a/src/SqlSquared/Path.purs b/src/SqlSquared/Path.purs index 116eb6b..8a2d896 100644 --- a/src/SqlSquared/Path.purs +++ b/src/SqlSquared/Path.purs @@ -10,43 +10,51 @@ module SqlSquared.Path ) where import Prelude -import Data.Either as E -import Data.NonEmpty ((:|)) -import Data.Path.Pathy as Pt -import Data.Path.Pathy.Gen as PtGen + import Control.Monad.Gen as Gen import Control.Monad.Rec.Class (class MonadRec) +import Data.Either as E +import Data.NonEmpty ((:|)) +import Pathy (posixParser, posixPrinter) +import Pathy as Pt +import Pathy.Gen as PtGen import SqlSquared.Utils ((∘)) -type AnyDirPath = E.Either (Pt.AbsDir Pt.Unsandboxed) (Pt.RelDir Pt.Unsandboxed) -type AnyFilePath = E.Either (Pt.AbsFile Pt.Unsandboxed) (Pt.RelFile Pt.Unsandboxed) +type AnyDirPath = E.Either Pt.AbsDir Pt.RelDir +type AnyFilePath = E.Either Pt.AbsFile Pt.RelFile printAnyDirPath :: AnyDirPath -> String -printAnyDirPath = E.either Pt.unsafePrintPath Pt.unsafePrintPath +printAnyDirPath = E.either + (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDirPath -parseAnyDirPath fail = Pt.parsePath +parseAnyDirPath fail = Pt.parsePath posixParser (pure ∘ E.Right) (pure ∘ E.Left) (const $ fail "Expected a directory path") (const $ fail "Expected a directory path") + (fail "Expected valid path") printAnyFilePath :: AnyFilePath -> String -printAnyFilePath = E.either Pt.unsafePrintPath Pt.unsafePrintPath +printAnyFilePath = E.either + (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFilePath -parseAnyFilePath fail = Pt.parsePath +parseAnyFilePath fail = Pt.parsePath posixParser (const $ fail "Expected a file path") (const $ fail "Expected a file path") (pure ∘ E.Right) (pure ∘ E.Left) + (fail "Expected valid path") genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFilePath genAnyFilePath = Gen.oneOf - $ (E.Left ∘ Pt.unsandbox <$> PtGen.genAbsFilePath) - :| [E.Right ∘ Pt.unsandbox <$> PtGen.genRelFilePath] + $ (E.Left <$> PtGen.genAbsFilePath) + :| [E.Right <$> PtGen.genRelFilePath] genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDirPath genAnyDirPath = Gen.oneOf - $ (E.Left ∘ Pt.unsandbox <$> PtGen.genAbsDirPath) - :| [E.Right ∘ Pt.unsandbox <$> PtGen.genRelDirPath] + $ (E.Left <$> PtGen.genAbsDirPath) + :| [E.Right <$> PtGen.genRelDirPath] diff --git a/test/src/Constructors.purs b/test/src/Constructors.purs index b681d29..38a241c 100644 --- a/test/src/Constructors.purs +++ b/test/src/Constructors.purs @@ -2,16 +2,15 @@ module Test.Constructors where import Prelude -import Data.List as L +import Data.Either as E import Data.Lens ((.~), (<>~), (?~)) +import Data.List as L import Data.Maybe (Maybe(..)) import Data.NonEmpty as NE -import Data.Either as E -import Data.Path.Pathy as Pt - +import Data.Symbol (SProxy(..)) +import Pathy as Pt import SqlSquared as S import SqlSquared.Utils ((×), (∘)) - import Test.Unit (suite, test, TestSuite) import Test.Unit.Assert as Assert @@ -26,9 +25,9 @@ selectQuery = { alias: Nothing , path: E.Left $ Pt.rootDir - Pt. Pt.dir "mongo" - Pt. Pt.dir "testDb" - Pt. Pt.file "patients" + Pt. Pt.dir (SProxy :: SProxy "mongo") + Pt. Pt.dir (SProxy :: SProxy "testDb") + Pt. Pt.file (SProxy :: SProxy "patients") }) ( Just $ S.binop S.Eq (S.ident "quux") (S.num 12.0) ) ( Just $ S.groupBy [ S.ident "zzz" ] # S.having ( S.binop S.Gt (S.ident "ooo") ( S.int 2)) ) @@ -53,9 +52,9 @@ buildSelectQuery = { alias: Nothing , path: E.Left $ Pt.rootDir - Pt. Pt.dir "mongo" - Pt. Pt.dir "testDb" - Pt. Pt.file "patients" + Pt. Pt.dir (SProxy :: SProxy "mongo") + Pt. Pt.dir (SProxy :: SProxy "testDb") + Pt. Pt.file (SProxy :: SProxy "patients") })) ∘ (S._filter ?~ S.binop S.Eq (S.ident "quux") (S.num 12.0)) From 08ed0e9c574f2fa5dc56a62b9b5e547dc1c18941 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Tue, 27 Feb 2018 15:45:15 +0400 Subject: [PATCH 2/3] use AnyDir and AnyFile from pathy --- src/SqlSquared/Path.purs | 34 ++++++++++++-------------- src/SqlSquared/Signature.purs | 2 +- src/SqlSquared/Signature/Relation.purs | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/SqlSquared/Path.purs b/src/SqlSquared/Path.purs index 8a2d896..294afe0 100644 --- a/src/SqlSquared/Path.purs +++ b/src/SqlSquared/Path.purs @@ -1,12 +1,11 @@ module SqlSquared.Path - ( AnyFilePath - , AnyDirPath - , parseAnyFilePath + ( parseAnyFilePath , printAnyFilePath , parseAnyDirPath , printAnyDirPath , genAnyFilePath , genAnyDirPath + , module PathyTypeReexprts ) where import Prelude @@ -15,46 +14,45 @@ import Control.Monad.Gen as Gen import Control.Monad.Rec.Class (class MonadRec) import Data.Either as E import Data.NonEmpty ((:|)) -import Pathy (posixParser, posixPrinter) import Pathy as Pt +import Pathy (AnyDir, AnyFile) as PathyTypeReexprts +import Pathy (AnyDir, AnyFile) import Pathy.Gen as PtGen import SqlSquared.Utils ((∘)) -type AnyDirPath = E.Either Pt.AbsDir Pt.RelDir -type AnyFilePath = E.Either Pt.AbsFile Pt.RelFile -printAnyDirPath :: AnyDirPath -> String +printAnyDirPath :: AnyDir -> String printAnyDirPath = E.either - (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) - (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) -parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDirPath -parseAnyDirPath fail = Pt.parsePath posixParser +parseAnyDirPath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyDir +parseAnyDirPath fail = Pt.parsePath Pt.posixParser (pure ∘ E.Right) (pure ∘ E.Left) (const $ fail "Expected a directory path") (const $ fail "Expected a directory path") (fail "Expected valid path") -printAnyFilePath :: AnyFilePath -> String +printAnyFilePath :: AnyFile -> String printAnyFilePath = E.either - (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) - (Pt.sandboxAny >>> Pt.unsafePrintPath posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) + (Pt.sandboxAny >>> Pt.unsafePrintPath Pt.posixPrinter) -parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFilePath -parseAnyFilePath fail = Pt.parsePath posixParser +parseAnyFilePath :: forall m. Applicative m => (forall a. String -> m a) -> String -> m AnyFile +parseAnyFilePath fail = Pt.parsePath Pt.posixParser (const $ fail "Expected a file path") (const $ fail "Expected a file path") (pure ∘ E.Right) (pure ∘ E.Left) (fail "Expected valid path") -genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFilePath +genAnyFilePath :: forall m. Gen.MonadGen m => MonadRec m => m AnyFile genAnyFilePath = Gen.oneOf $ (E.Left <$> PtGen.genAbsFilePath) :| [E.Right <$> PtGen.genRelFilePath] -genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDirPath +genAnyDirPath :: forall m. Gen.MonadGen m => MonadRec m => m AnyDir genAnyDirPath = Gen.oneOf $ (E.Left <$> PtGen.genAbsDirPath) :| [E.Right <$> PtGen.genRelDirPath] diff --git a/src/SqlSquared/Signature.purs b/src/SqlSquared/Signature.purs index cca8758..08fb7fa 100644 --- a/src/SqlSquared/Signature.purs +++ b/src/SqlSquared/Signature.purs @@ -140,7 +140,7 @@ data SqlF literal a | Parens a data SqlDeclF a - = Import Pt.AnyDirPath + = Import Pt.AnyDir | FunctionDecl (FunctionDeclR a) newtype SqlModuleF a = diff --git a/src/SqlSquared/Signature/Relation.purs b/src/SqlSquared/Signature/Relation.purs index 5ed38de..60cba33 100644 --- a/src/SqlSquared/Signature/Relation.purs +++ b/src/SqlSquared/Signature/Relation.purs @@ -36,7 +36,7 @@ type VariRelR = } type TableRelR = - { path ∷ Pt.AnyFilePath + { path ∷ Pt.AnyFile , alias ∷ Maybe String } From 422a2c8a0be98d7e187dd3baf9fef766ca403957 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Tue, 20 Mar 2018 21:59:01 +0100 Subject: [PATCH 3/3] Use published version of ps-pathy --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index f6e1ffa..e53cf7c 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,7 @@ "dependencies": { "purescript-prelude": "^3.1.0", "purescript-matryoshka": "^0.3.0", - "purescript-pathy": "safareli/purescript-pathy#refactor", + "purescript-pathy": "^5.0.0", "purescript-profunctor": "^3.2.0", "purescript-profunctor-lenses": "^3.2.0", "purescript-ejson": "^10.0.1",