Skip to content

PureScript 0.12 updates #35

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

Merged
merged 1 commit into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: 9
install:
- npm install -g bower
- npm install
Expand Down
20 changes: 10 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
"package.json"
],
"dependencies": {
"purescript-console": "^3.0.0",
"purescript-exceptions": "^3.0.0",
"purescript-lists": "^4.0.0",
"purescript-partial": "^1.2.0",
"purescript-profunctor": "^3.0.0",
"purescript-strings": "^3.5.0",
"purescript-transformers": "^3.0.0",
"purescript-unsafe-coerce": "^3.0.0",
"purescript-typelevel-prelude": "^2.6.0"
"purescript-console": "^4.0.1",
"purescript-exceptions": "^4.0.0",
"purescript-lists": "^5.0.0",
"purescript-partial": "^2.0.0",
"purescript-profunctor": "^4.0.0",
"purescript-strings": "^4.0.0",
"purescript-transformers": "^4.1.0",
"purescript-unsafe-coerce": "^4.0.0",
"purescript-typelevel-prelude": "^3.0.0"
},
"devDependencies": {
"purescript-quickcheck": "^4.0.0"
"purescript-quickcheck": "^5.0.0"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"test": "pulp test"
},
"devDependencies": {
"pulp": "^11.0.0",
"pulp": "^12.3.0",
"purescript-psa": "^0.5.0",
"purescript": "^0.11.1",
"purescript": "^0.12.0",
"rimraf": "^2.5.4"
}
}
2 changes: 1 addition & 1 deletion src/Pathy/Gen.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Data.Foldable (foldr)
import Data.List as L
import Data.NonEmpty ((:|))
import Data.String.Gen as SG
import Data.String.NonEmpty (cons)
import Data.String.NonEmpty.CodeUnits (cons)
import Pathy (AbsDir, AbsFile, AbsPath, Dir, File, RelDir, RelFile, RelPath, (</>))
import Pathy as P

Expand Down
10 changes: 5 additions & 5 deletions src/Pathy/Name.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
import Data.Newtype (class Newtype)
import Data.String as S
import Data.String.NonEmpty (NonEmptyString)
import Data.String.NonEmpty as NES
import Data.String.NonEmpty.CodeUnits as NES
import Data.Symbol (class IsSymbol, SProxy(..))
import Data.Symbol (reflectSymbol) as Symbol
import Pathy.Phantom (kind DirOrFile)
Expand Down Expand Up @@ -34,7 +34,7 @@ instance showName :: Show (Name a) where
-- | splitName (Name "foo.baz") == { name: "foo", extension: Just "baz" }
-- | ```
-- | _Note, in real code all strings from this examples would be `NonEmptyString`._
-- |
-- |
-- | Also for any `Name` this property holds:
-- | ```purescript
-- | joinName <<< splitName = id
Expand All @@ -61,7 +61,7 @@ joinName { name, ext } = Name $ case ext of
Just ext' -> name <> NES.singleton '.' <> ext'

-- | Retrieves the extension of a name. also see [`splitName`](#v:splitName)
-- |
-- |
-- | ```purescript
-- | extension (Name ".foo") == Nothing
-- | extension (Name "foo.") == Nothing
Expand All @@ -76,7 +76,7 @@ extension = splitName >>> _.ext
-- | or modified. see [`splitName`](#v:splitName) and [`joinName`](#v:joinName)
-- | for how a `Name` is split into name and extention part and joined back
-- | into a `Name`.
-- |
-- |
-- | Also for any `Name` this property holds:
-- | ```purescript
-- | alterExtension id = id
Expand All @@ -89,7 +89,7 @@ alterExtension
alterExtension f n =
let spn = splitName n
in joinName spn{ext = f spn.ext}

-- | A class for creating `Name` values from type-level strings. This allows us
-- | to guarantee that a name is not empty at compile-time.
class IsName sym where
Expand Down
4 changes: 3 additions & 1 deletion src/Pathy/Parser.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import Data.Either (Either(..), either)
import Data.List (List(..), (:))
import Data.List as L
import Data.Maybe (Maybe(..))
import Data.String as S
import Data.String (split) as S
import Data.String.CodeUnits (take, takeRight) as S
import Data.String.NonEmpty (NonEmptyString)
import Data.String.NonEmpty as NES
import Data.String.Pattern (Pattern(..)) as S
import Pathy.Name (Name(..))
import Pathy.Path (AbsDir, AbsFile, Path, RelDir, RelFile, currentDir, extendPath, parentOf, rootDir)
import Pathy.Phantom (class IsRelOrAbs, Dir)
Expand Down
8 changes: 4 additions & 4 deletions src/Pathy/Phantom.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class IsRelOrAbs (a :: RelOrAbs) where
-> f a b
-> r

instance relIsRelOrAbs :: IsRelOrAbs Rel where onRelOrAbs f _ = f id
instance absIsRelOrAbs :: IsRelOrAbs Abs where onRelOrAbs _ f = f id
instance relIsRelOrAbs :: IsRelOrAbs Rel where onRelOrAbs f _ = f identity
instance absIsRelOrAbs :: IsRelOrAbs Abs where onRelOrAbs _ f = f identity

-- | Folds over a value that uses `RelOrAbs` to produce a new result.
foldRelOrAbs
Expand Down Expand Up @@ -59,8 +59,8 @@ class IsDirOrFile (b :: DirOrFile) where
-> f b
-> r

instance isDirOrFileDir :: IsDirOrFile Dir where onDirOrFile f _ = f id
instance isDirOrFileFile :: IsDirOrFile File where onDirOrFile _ f = f id
instance isDirOrFileDir :: IsDirOrFile Dir where onDirOrFile f _ = f identity
instance isDirOrFileFile :: IsDirOrFile File where onDirOrFile _ f = f identity

-- | Folds over a value that uses `DirOrFile` to produce a new result.
foldDirOrFile
Expand Down
14 changes: 8 additions & 6 deletions src/Pathy/Printer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ import Prelude

import Data.Foldable (fold)
import Data.Maybe (Maybe(..), maybe)
import Data.Monoid (class Monoid)
import Data.Newtype (class Newtype, un, unwrap)
import Data.String as Str
import Data.String (Pattern(..)) as Str
import Data.String.CodeUnits (singleton) as Str
import Data.String.NonEmpty (NonEmptyString)
import Data.String.NonEmpty as NES
import Data.String.NonEmpty (NonEmptyReplacement(..), replaceAll, toString, unsafeFromString) as NES
import Data.String.NonEmpty.CodeUnits (cons, singleton) as NES
import Partial.Unsafe (unsafePartial)
import Pathy.Name (Name)
import Pathy.Path (Path, foldPath, (</>))
import Pathy.Phantom (class IsDirOrFile, class IsRelOrAbs, Dir, Rel, foldDirOrFile, foldRelOrAbs, kind DirOrFile, kind RelOrAbs)
import Pathy.Sandboxed (SandboxedPath, sandboxRoot, unsandbox)
import Prim.TypeError (class Warn, Text)

-- | A `Printer` defines options for printing paths.
-- |
Expand Down Expand Up @@ -81,7 +83,7 @@ printPath r sp =
in
printPathRep
r
(foldRelOrAbs (root </> _) id p)
(foldRelOrAbs (root </> _) identity p)

-- | Prints a `SandboxedPath` into its canonical `String` representation, using
-- | the specified printer. This will print a relative path if `b ~ Rel`, which
Expand All @@ -100,7 +102,7 @@ unsafePrintPath r sp = printPathRep r (unsandbox sp)
-- | compile time as a reminder!
debugPrintPath
:: forall a b
. Warn "debugPrintPath usage"
. Warn (Text "debugPrintPath usage")
=> IsRelOrAbs a
=> IsDirOrFile b
=> Printer
Expand Down Expand Up @@ -155,7 +157,7 @@ instance semigroupEscaper :: Semigroup Escaper where
append (Escaper e1) (Escaper e2) = Escaper (e1 <<< e2)

instance monoidEscaper :: Monoid Escaper where
mempty = Escaper id
mempty = Escaper identity

-- | An escaper that replaces all `'/'` characters in a name with `'-'`s.
slashEscaper :: Escaper
Expand Down
2 changes: 1 addition & 1 deletion src/Pathy/Sandboxed.purs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sandbox
=> Path Abs Dir
-> Path a b
-> Maybe (SandboxedPath a b)
sandbox root = map (SandboxedPath root) <<< onRelOrAbs (go (root </> _)) (go id)
sandbox root = map (SandboxedPath root) <<< onRelOrAbs (go (root </> _)) (go identity)
where
go :: forall p. (p -> Path Abs b) -> (p -> Path a b) -> p -> Maybe (Path a b)
go f coe p =
Expand Down
19 changes: 10 additions & 9 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ module Test.Main where

import Prelude

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, info)
import Control.Monad.Eff.Exception (EXCEPTION, throw)
import Data.Maybe (Maybe(..), maybe)
import Data.Newtype (un)
import Data.NonEmpty ((:|))
import Data.String as Str
import Data.String.NonEmpty (NonEmptyString)
import Data.String.NonEmpty as NES
import Data.String.NonEmpty (fromString) as NES
import Data.String.NonEmpty.CodeUnits (singleton) as NES
import Data.Symbol (SProxy(..))
import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect.Console (info)
import Effect.Exception (throw)
import Pathy (class IsDirOrFile, class IsRelOrAbs, Abs, Dir, Name(..), Path, Rel, alterExtension, currentDir, debugPrintPath, dir, extension, file, in', joinName, parentOf, parseAbsDir, parseAbsFile, parseRelDir, parseRelFile, peel, posixParser, posixPrinter, printPath, relativeTo, rename, rootDir, sandbox, sandboxAny, splitName, unsandbox, windowsPrinter, (<..>), (<.>), (</>))
import Pathy.Gen as PG
import Pathy.Name (reflectName)
Expand All @@ -21,14 +22,14 @@ import Test.QuickCheck as QC
import Test.QuickCheck.Gen as Gen
import Unsafe.Coerce (unsafeCoerce)

test :: forall a eff. Show a => Eq a => String -> a -> a -> Eff (console :: CONSOLE, exception :: EXCEPTION | eff) Unit
test :: forall a. Show a => Eq a => String -> a -> a -> Effect Unit
test name actual expected= do
info $ "Test: " <> name
if expected == actual
then info $ "Passed: " <> (show expected)
else throw $ "Failed:\n Expected: " <> (show expected) <> "\n Actual: " <> (show actual)

test' :: forall a b eff. IsRelOrAbs a => IsDirOrFile b => String -> Path a b -> String -> Eff (console :: CONSOLE, exception :: EXCEPTION | eff) Unit
test' :: forall a b. IsRelOrAbs a => IsDirOrFile b => String -> Path a b -> String -> Effect Unit
test' n p s = test n (printTestPath p) s

pathPart ∷ Gen.Gen NonEmptyString
Expand Down Expand Up @@ -89,12 +90,12 @@ genAmbigiousName =
checkAlterExtensionId :: Gen.Gen QC.Result
checkAlterExtensionId = do
n <- genAmbigiousName
pure $ alterExtension id n === id n
pure $ alterExtension identity n === identity n

checkJoinSplitNameId :: Gen.Gen QC.Result
checkJoinSplitNameId = do
n <- genAmbigiousName
pure $ joinName (splitName n) === id n
pure $ joinName (splitName n) === identity n

checkPeelIn :: forall b. IsDirOrFile b => Gen.Gen (Path Abs b) -> Gen.Gen QC.Result
checkPeelIn gen = do
Expand All @@ -118,7 +119,7 @@ checkRelative gen = do
<> "\n\trel: " <> printTestPath rel
<> "\n\tp1': " <> printTestPath p1'

main :: QC.QC () Unit
main :: Effect Unit
main = do
info "checking `parse <<< print` for `AbsDir`" *> QC.quickCheck parsePrintAbsDirPath
info "checking `parse <<< print` for `AbsFile`" *> QC.quickCheck parsePrintAbsFilePath
Expand Down