Skip to content

Commit 47992a7

Browse files
authored
Merge pull request #35 from therealnicksaunders/purescript-0.12
PureScript 0.12 updates
2 parents 52d2315 + 08860f5 commit 47992a7

File tree

10 files changed

+45
-40
lines changed

10 files changed

+45
-40
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: 9
55
install:
66
- npm install -g bower
77
- npm install

bower.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-console": "^3.0.0",
21-
"purescript-exceptions": "^3.0.0",
22-
"purescript-lists": "^4.0.0",
23-
"purescript-partial": "^1.2.0",
24-
"purescript-profunctor": "^3.0.0",
25-
"purescript-strings": "^3.5.0",
26-
"purescript-transformers": "^3.0.0",
27-
"purescript-unsafe-coerce": "^3.0.0",
28-
"purescript-typelevel-prelude": "^2.6.0"
20+
"purescript-console": "^4.0.1",
21+
"purescript-exceptions": "^4.0.0",
22+
"purescript-lists": "^5.0.0",
23+
"purescript-partial": "^2.0.0",
24+
"purescript-profunctor": "^4.0.0",
25+
"purescript-strings": "^4.0.0",
26+
"purescript-transformers": "^4.1.0",
27+
"purescript-unsafe-coerce": "^4.0.0",
28+
"purescript-typelevel-prelude": "^3.0.0"
2929
},
3030
"devDependencies": {
31-
"purescript-quickcheck": "^4.0.0"
31+
"purescript-quickcheck": "^5.0.0"
3232
}
3333
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^11.0.0",
9+
"pulp": "^12.3.0",
1010
"purescript-psa": "^0.5.0",
11-
"purescript": "^0.11.1",
11+
"purescript": "^0.12.0",
1212
"rimraf": "^2.5.4"
1313
}
1414
}

src/Pathy/Gen.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Data.Foldable (foldr)
2121
import Data.List as L
2222
import Data.NonEmpty ((:|))
2323
import Data.String.Gen as SG
24-
import Data.String.NonEmpty (cons)
24+
import Data.String.NonEmpty.CodeUnits (cons)
2525
import Pathy (AbsDir, AbsFile, AbsPath, Dir, File, RelDir, RelFile, RelPath, (</>))
2626
import Pathy as P
2727

src/Pathy/Name.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
66
import Data.Newtype (class Newtype)
77
import Data.String as S
88
import Data.String.NonEmpty (NonEmptyString)
9-
import Data.String.NonEmpty as NES
9+
import Data.String.NonEmpty.CodeUnits as NES
1010
import Data.Symbol (class IsSymbol, SProxy(..))
1111
import Data.Symbol (reflectSymbol) as Symbol
1212
import Pathy.Phantom (kind DirOrFile)
@@ -34,7 +34,7 @@ instance showName :: Show (Name a) where
3434
-- | splitName (Name "foo.baz") == { name: "foo", extension: Just "baz" }
3535
-- | ```
3636
-- | _Note, in real code all strings from this examples would be `NonEmptyString`._
37-
-- |
37+
-- |
3838
-- | Also for any `Name` this property holds:
3939
-- | ```purescript
4040
-- | joinName <<< splitName = id
@@ -61,7 +61,7 @@ joinName { name, ext } = Name $ case ext of
6161
Just ext' -> name <> NES.singleton '.' <> ext'
6262

6363
-- | Retrieves the extension of a name. also see [`splitName`](#v:splitName)
64-
-- |
64+
-- |
6565
-- | ```purescript
6666
-- | extension (Name ".foo") == Nothing
6767
-- | extension (Name "foo.") == Nothing
@@ -76,7 +76,7 @@ extension = splitName >>> _.ext
7676
-- | or modified. see [`splitName`](#v:splitName) and [`joinName`](#v:joinName)
7777
-- | for how a `Name` is split into name and extention part and joined back
7878
-- | into a `Name`.
79-
-- |
79+
-- |
8080
-- | Also for any `Name` this property holds:
8181
-- | ```purescript
8282
-- | alterExtension id = id
@@ -89,7 +89,7 @@ alterExtension
8989
alterExtension f n =
9090
let spn = splitName n
9191
in joinName spn{ext = f spn.ext}
92-
92+
9393
-- | A class for creating `Name` values from type-level strings. This allows us
9494
-- | to guarantee that a name is not empty at compile-time.
9595
class IsName sym where

src/Pathy/Parser.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import Data.Either (Either(..), either)
1616
import Data.List (List(..), (:))
1717
import Data.List as L
1818
import Data.Maybe (Maybe(..))
19-
import Data.String as S
19+
import Data.String (split) as S
20+
import Data.String.CodeUnits (take, takeRight) as S
2021
import Data.String.NonEmpty (NonEmptyString)
2122
import Data.String.NonEmpty as NES
23+
import Data.String.Pattern (Pattern(..)) as S
2224
import Pathy.Name (Name(..))
2325
import Pathy.Path (AbsDir, AbsFile, Path, RelDir, RelFile, currentDir, extendPath, parentOf, rootDir)
2426
import Pathy.Phantom (class IsRelOrAbs, Dir)

src/Pathy/Phantom.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class IsRelOrAbs (a :: RelOrAbs) where
2424
-> f a b
2525
-> r
2626

27-
instance relIsRelOrAbs :: IsRelOrAbs Rel where onRelOrAbs f _ = f id
28-
instance absIsRelOrAbs :: IsRelOrAbs Abs where onRelOrAbs _ f = f id
27+
instance relIsRelOrAbs :: IsRelOrAbs Rel where onRelOrAbs f _ = f identity
28+
instance absIsRelOrAbs :: IsRelOrAbs Abs where onRelOrAbs _ f = f identity
2929

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

62-
instance isDirOrFileDir :: IsDirOrFile Dir where onDirOrFile f _ = f id
63-
instance isDirOrFileFile :: IsDirOrFile File where onDirOrFile _ f = f id
62+
instance isDirOrFileDir :: IsDirOrFile Dir where onDirOrFile f _ = f identity
63+
instance isDirOrFileFile :: IsDirOrFile File where onDirOrFile _ f = f identity
6464

6565
-- | Folds over a value that uses `DirOrFile` to produce a new result.
6666
foldDirOrFile

src/Pathy/Printer.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ import Prelude
1616

1717
import Data.Foldable (fold)
1818
import Data.Maybe (Maybe(..), maybe)
19-
import Data.Monoid (class Monoid)
2019
import Data.Newtype (class Newtype, un, unwrap)
21-
import Data.String as Str
20+
import Data.String (Pattern(..)) as Str
21+
import Data.String.CodeUnits (singleton) as Str
2222
import Data.String.NonEmpty (NonEmptyString)
23-
import Data.String.NonEmpty as NES
23+
import Data.String.NonEmpty (NonEmptyReplacement(..), replaceAll, toString, unsafeFromString) as NES
24+
import Data.String.NonEmpty.CodeUnits (cons, singleton) as NES
2425
import Partial.Unsafe (unsafePartial)
2526
import Pathy.Name (Name)
2627
import Pathy.Path (Path, foldPath, (</>))
2728
import Pathy.Phantom (class IsDirOrFile, class IsRelOrAbs, Dir, Rel, foldDirOrFile, foldRelOrAbs, kind DirOrFile, kind RelOrAbs)
2829
import Pathy.Sandboxed (SandboxedPath, sandboxRoot, unsandbox)
30+
import Prim.TypeError (class Warn, Text)
2931

3032
-- | A `Printer` defines options for printing paths.
3133
-- |
@@ -81,7 +83,7 @@ printPath r sp =
8183
in
8284
printPathRep
8385
r
84-
(foldRelOrAbs (root </> _) id p)
86+
(foldRelOrAbs (root </> _) identity p)
8587

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

157159
instance monoidEscaper :: Monoid Escaper where
158-
mempty = Escaper id
160+
mempty = Escaper identity
159161

160162
-- | An escaper that replaces all `'/'` characters in a name with `'-'`s.
161163
slashEscaper :: Escaper

src/Pathy/Sandboxed.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sandbox
2929
=> Path Abs Dir
3030
-> Path a b
3131
-> Maybe (SandboxedPath a b)
32-
sandbox root = map (SandboxedPath root) <<< onRelOrAbs (go (root </> _)) (go id)
32+
sandbox root = map (SandboxedPath root) <<< onRelOrAbs (go (root </> _)) (go identity)
3333
where
3434
go :: forall p. (p -> Path Abs b) -> (p -> Path a b) -> p -> Maybe (Path a b)
3535
go f coe p =

test/Main.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff)
6-
import Control.Monad.Eff.Console (CONSOLE, info)
7-
import Control.Monad.Eff.Exception (EXCEPTION, throw)
85
import Data.Maybe (Maybe(..), maybe)
96
import Data.Newtype (un)
107
import Data.NonEmpty ((:|))
118
import Data.String as Str
129
import Data.String.NonEmpty (NonEmptyString)
13-
import Data.String.NonEmpty as NES
10+
import Data.String.NonEmpty (fromString) as NES
11+
import Data.String.NonEmpty.CodeUnits (singleton) as NES
1412
import Data.Symbol (SProxy(..))
1513
import Data.Tuple (Tuple(..))
14+
import Effect (Effect)
15+
import Effect.Console (info)
16+
import Effect.Exception (throw)
1617
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, (<..>), (<.>), (</>))
1718
import Pathy.Gen as PG
1819
import Pathy.Name (reflectName)
@@ -21,14 +22,14 @@ import Test.QuickCheck as QC
2122
import Test.QuickCheck.Gen as Gen
2223
import Unsafe.Coerce (unsafeCoerce)
2324

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

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

3435
pathPart Gen.Gen NonEmptyString
@@ -89,12 +90,12 @@ genAmbigiousName =
8990
checkAlterExtensionId :: Gen.Gen QC.Result
9091
checkAlterExtensionId = do
9192
n <- genAmbigiousName
92-
pure $ alterExtension id n === id n
93+
pure $ alterExtension identity n === identity n
9394

9495
checkJoinSplitNameId :: Gen.Gen QC.Result
9596
checkJoinSplitNameId = do
9697
n <- genAmbigiousName
97-
pure $ joinName (splitName n) === id n
98+
pure $ joinName (splitName n) === identity n
9899

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

121-
main :: QC.QC () Unit
122+
main :: Effect Unit
122123
main = do
123124
info "checking `parse <<< print` for `AbsDir`" *> QC.quickCheck parsePrintAbsDirPath
124125
info "checking `parse <<< print` for `AbsFile`" *> QC.quickCheck parsePrintAbsFilePath

0 commit comments

Comments
 (0)