Skip to content

Commit e75a4c1

Browse files
committed
Add unsafeThrowException and unsafeThrow
1 parent c9241c9 commit e75a4c1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Module Control.Monad.Eff.Exception.Unsafe
2+
3+
#### `unsafeThrowException`
4+
5+
``` purescript
6+
unsafeThrowException :: forall a. Error -> a
7+
```
8+
9+
Throw an exception in pure code. This function should be used very
10+
sparingly, as it can cause unexpected crashes at runtime.
11+
12+
#### `unsafeThrow`
13+
14+
``` purescript
15+
unsafeThrow :: forall a. String -> a
16+
```
17+
18+
Defined as `unsafeThrowException <<< error`.
19+
20+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Control.Monad.Eff.Exception.Unsafe where
2+
3+
import Prelude
4+
import Control.Monad.Eff
5+
import Control.Monad.Eff.Unsafe
6+
import Control.Monad.Eff.Exception
7+
8+
-- | Throw an exception in pure code. This function should be used very
9+
-- | sparingly, as it can cause unexpected crashes at runtime.
10+
unsafeThrowException :: forall a. Error -> a
11+
unsafeThrowException = unsafeRunEff <<< throwException
12+
where
13+
unsafeRunEff :: forall e b. Eff e b -> b
14+
unsafeRunEff = runPure <<< unsafeInterleaveEff
15+
16+
-- | Defined as `unsafeThrowException <<< error`.
17+
unsafeThrow :: forall a. String -> a
18+
unsafeThrow = unsafeThrowException <<< error

0 commit comments

Comments
 (0)