Skip to content

Commit 7fb7e29

Browse files
Update for v0.14.0-rc2 (#16)
* Update tag to v0.14.0-rc2 * Fix compiler warnings for v0.14.0-rc2 * Remove outher function in _crashWith FFI * Move unsafePartial's original doc comment down to function * Add note about unsafePartial's FFI and explain its type signature * Remove deprecated `unsafePartialBecause` * Remove unsafePartialBecause in test code
1 parent ab05e97 commit 7fb7e29

6 files changed

Lines changed: 20 additions & 17 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ node_js: 6
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:
8-
- TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
8+
- TAG=v0.14.0-rc2
9+
# - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
910
- curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
1011
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
1112
- chmod a+x $HOME/purescript

src/Partial.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
// module Partial
44

5-
exports.crashWith = function () {
6-
return function (msg) {
7-
throw new Error(msg);
8-
};
5+
exports._crashWith = function (msg) {
6+
throw new Error(msg);
97
};

src/Partial.purs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ crash :: forall a. Partial => a
99
crash = crashWith "Partial.crash: partial function"
1010

1111
-- | A partial function which crashes on any input with the specified message.
12-
foreign import crashWith :: forall a. Partial => String -> a
12+
crashWith :: forall a. Partial => String -> a
13+
crashWith = _crashWith
14+
15+
foreign import _crashWith :: forall a. String -> a

src/Partial/Unsafe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
// module Partial.Unsafe
44

5-
exports.unsafePartial = function (f) {
5+
exports._unsafePartial = function (f) {
66
return f();
77
};

src/Partial/Unsafe.purs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
-- | See the README for more documentation.
33
module Partial.Unsafe
44
( unsafePartial
5-
, unsafePartialBecause
65
, unsafeCrashWith
76
) where
87

98
import Partial (crashWith)
109

11-
-- | Discharge a partiality constraint, unsafely.
12-
foreign import unsafePartial :: forall a. (Partial => a) -> a
10+
-- Note: this function's type signature is more like
11+
-- `(Unit -> a) -> a`. However, we would need to use
12+
-- `unsafeCoerce` to make this compile, incurring
13+
-- either a dependency or reimplementing it here.
14+
-- Rather than doing that, we'll use a type signature
15+
-- of `a -> b` instead.
16+
foreign import _unsafePartial :: forall a b. a -> b
1317

14-
-- | *deprecated:* use `unsafePartial` instead.
15-
unsafePartialBecause :: forall a. String -> (Partial => a) -> a
16-
unsafePartialBecause _ x = unsafePartial x
18+
-- | Discharge a partiality constraint, unsafely.
19+
unsafePartial :: forall a. (Partial => a) -> a
20+
unsafePartial = _unsafePartial
1721

1822
-- | A function which crashes with the specified error message.
1923
unsafeCrashWith :: forall a. String -> a

test/Main.purs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Test.Main where
22

33
import Partial (crashWith)
4-
import Partial.Unsafe (unsafePartial, unsafePartialBecause)
4+
import Partial.Unsafe (unsafePartial)
55

66
f :: Partial => Int -> Int
77
f 0 = 0
@@ -10,8 +10,5 @@ f _ = crashWith "f: partial function"
1010
safely :: Int
1111
safely = unsafePartial (f 0)
1212

13-
safely2 :: Int
14-
safely2 = unsafePartialBecause "calling f with argument 0 is guaranteed to be safe" (f 0)
15-
1613
main :: forall a. a -> {}
1714
main _ = {}

0 commit comments

Comments
 (0)