Skip to content

Updates for PureScript 0.8 #14

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
Mar 16, 2016
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
5 changes: 5 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"preset": "grunt",
"disallowSpacesInFunctionExpression": null,
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": null,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
Expand Down
5 changes: 3 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"freeze": true,
"funcscope": true,
"futurehostile": true,
"globalstrict": true,
"strict": "global",
"latedef": true,
"maxparams": 1,
"noarg": true,
Expand All @@ -15,5 +15,6 @@
"singleGroups": true,
"undef": true,
"unused": true,
"eqnull": true
"eqnull": true,
"predef": ["exports"]
}
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
language: node_js
sudo: false
node_js:
- 0.10
sudo: required
dist: trusty
node_js: 5
env:
- PATH=$HOME/purescript:$PATH
install:
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
- chmod a+x $HOME/purescript
- npm install -g bower
- npm install
- bower install
script:
- npm run build
after_success:
- >-
test $TRAVIS_TAG &&
psc-publish > .pursuit.json &&
curl -X POST http://pursuit.purescript.org/packages \
-d @.pursuit.json \
-H 'Accept: application/json' \
-H "Authorization: token ${GITHUB_TOKEN}"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Exception effects.
bower install purescript-exceptions
```

## Module documentation
## Documentation

- [Control.Monad.Eff.Exception](docs/Control/Monad/Eff/Exception.md)
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-exceptions).
7 changes: 2 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"name": "purescript-exceptions",
"homepage": "https://github.com/purescript/purescript-exceptions",
"description": "Exception effects",
"keywords": [
"purescript"
],
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -20,7 +17,7 @@
"package.json"
],
"dependencies": {
"purescript-eff": "^0.1.2",
"purescript-maybe": "^0.3.5"
"purescript-eff": "^1.0.0-rc.1",
"purescript-maybe": "^1.0.0-rc.1"
}
}
94 changes: 0 additions & 94 deletions docs/Control/Monad/Eff/Exception.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/Control/Monad/Eff/Exception/Unsafe.md

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"private": true,
"scripts": {
"postinstall": "pulp dep install",
"build": "jshint src && jscs src && pulp build && rimraf docs && pulp docs"
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src && jscs src && pulp build",
"test": "jshint src && jscs src && pulp test"
},
"devDependencies": {
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"pulp": "^4.0.2",
"rimraf": "^2.4.1"
"jscs": "^2.8.0",
"jshint": "^2.9.1",
"pulp": "^8.1.0",
"rimraf": "^2.5.0"
}
}
27 changes: 20 additions & 7 deletions src/Control/Monad/Eff/Exception.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- | with JavaScript exceptions.

module Control.Monad.Eff.Exception
( EXCEPTION()
, Error()
( EXCEPTION
, Error
, error
, message
, stack
Expand All @@ -12,9 +12,11 @@ module Control.Monad.Eff.Exception
, throw
) where

import Prelude
import Control.Monad.Eff (Eff)
import Control.Semigroupoid ((<<<))

import Data.Maybe (Maybe(..))
import Control.Monad.Eff (Eff())
import Data.Show (class Show)

-- | This effect is used to annotate code which possibly throws exceptions
foreign import data EXCEPTION :: !
Expand All @@ -37,7 +39,11 @@ foreign import message :: Error -> String
stack :: Error -> Maybe String
stack = stackImpl Just Nothing

foreign import stackImpl :: (forall a. a -> Maybe a) -> (forall a. Maybe a) -> Error -> Maybe String
foreign import stackImpl
:: (forall a. a -> Maybe a)
-> (forall a. Maybe a)
-> Error
-> Maybe String

-- | Throw an exception
-- |
Expand All @@ -49,7 +55,10 @@ foreign import stackImpl :: (forall a. a -> Maybe a) -> (forall a. Maybe a) -> E
-- | when (x < 0) $ throwException $
-- | error "Expected a non-negative number"
-- | ```
foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION | eff) a
foreign import throwException
:: forall a eff
. Error
-> Eff (err :: EXCEPTION | eff) a

-- | Catch an exception by providing an exception handler.
-- |
Expand All @@ -61,7 +70,11 @@ foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION |
-- | main = catchException print do
-- | 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
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`.
Expand Down
6 changes: 3 additions & 3 deletions src/Control/Monad/Eff/Exception/Unsafe.purs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Control.Monad.Eff.Exception.Unsafe where

import Prelude
import Control.Monad.Eff.Unsafe
import Control.Monad.Eff.Exception
import Control.Monad.Eff.Exception (Error, error, throwException)
import Control.Monad.Eff.Unsafe (unsafePerformEff)
import Control.Semigroupoid ((<<<))

-- | Throw an exception in pure code. This function should be used very
-- | sparingly, as it can cause unexpected crashes at runtime.
Expand Down