Skip to content

Commit 36b2add

Browse files
authored
Merge pull request #8 from purescript/deprecate-unsafepartialbecause
Deprecate unsafePartialBecause; fixes #7
2 parents c8ca0bc + 9d5472d commit 36b2add

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/Partial/Unsafe.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,3 @@
55
exports.unsafePartial = function (f) {
66
return f();
77
};
8-
9-
exports.unsafePartialBecause = function (reason) {
10-
return function (f) {
11-
try {
12-
return exports.unsafePartial(f);
13-
} catch (err) {
14-
throw new Error("unsafePartial failed. The following " +
15-
"assumption was incorrect: '" + reason + "'.");
16-
}
17-
};
18-
};

src/Partial/Unsafe.purs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import Partial (crashWith)
1010
-- | Discharge a partiality constraint, unsafely.
1111
foreign import unsafePartial :: forall a. (Partial => a) -> a
1212

13-
-- | Discharge a partiality constraint, unsafely. Raises an exception with a
14-
-- | custom error message in the (unexpected) case where `unsafePartial` was
15-
-- | used incorrectly.
16-
foreign import unsafePartialBecause :: forall a. String -> (Partial => a) -> a
13+
-- | *deprecated:* use `unsafePartial` instead.
14+
unsafePartialBecause :: forall a. String -> (Partial => a) -> a
15+
unsafePartialBecause _ x = unsafePartial x
1716

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

0 commit comments

Comments
 (0)