Skip to content

Add throw (as in #8) #10

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
Dec 11, 2015
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
11 changes: 10 additions & 1 deletion docs/Control/Monad/Eff/Exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The type of Javascript errors

##### Instances
``` purescript
instance showError :: Show Error
Show Error
```

#### `error`
Expand Down Expand Up @@ -74,4 +74,13 @@ main = catchException print do
trace "Exceptions thrown in this block will be logged to the console"
```

#### `throw`

``` purescript
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
```

A shortcut allowing you to throw an error in one step. Defined as
`throwException <<< error`.


6 changes: 6 additions & 0 deletions src/Control/Monad/Eff/Exception.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Control.Monad.Eff.Exception
, message
, throwException
, catchException
, throw
) where

import Prelude
Expand Down Expand Up @@ -53,3 +54,8 @@ foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION |
-- | trace "Exceptions thrown in this block will be logged to the console"
-- | ```
foreign import catchException :: forall a eff. (Error -> Eff eff a) -> Eff (err :: EXCEPTION | eff) a -> Eff eff a

-- | A shortcut allowing you to throw an error in one step. Defined as
-- | `throwException <<< error`.
throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a
throw = throwException <<< error