Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #11 from purescript/0.8-updates
Browse files Browse the repository at this point in the history
Updates for PureScript 0.8
  • Loading branch information
garyb committed Mar 1, 2016
2 parents 2c81248 + 5843d72 commit ce2fa05
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 203 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
/bower_components/
/node_modules/
/output/
/tmp/
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"]
}
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
language: node_js
sudo: false
node_js:
- 0.10
- 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
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}"
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
[![Build Status](https://travis-ci.org/purescript/purescript-eff.svg?branch=master)](https://travis-ci.org/purescript/purescript-eff)
[![Dependency Status](https://www.versioneye.com/user/projects/55848cde3638610015000408/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55848cde3638610015000408)

The `Eff` monad, for handling native side effects. For use with compiler version >= 0.7.
The `Eff` monad, for handling native side effects.

## Installation

```
bower install purescript-eff
```

## Module documentation
## Documentation

- [Control.Monad.Eff](docs/Control/Monad/Eff.md)
- [Control.Monad.Eff.Unsafe](docs/Control/Monad/Eff/Unsafe.md)
- [Control.Monad.Eff.Class](docs/Control/Monad/Eff/Class.md)
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-eff).
6 changes: 1 addition & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"name": "purescript-eff",
"homepage": "https://github.com/purescript/purescript-eff",
"description": "The Eff monad, for handling native side effects",
"keywords": [
"purescript"
],
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -17,10 +14,9 @@
"output",
"test",
"bower.json",
"gulpfile.js",
"package.json"
],
"dependencies": {
"purescript-prelude": "^0.1.0"
"purescript-prelude": "^1.0.0-rc.1"
}
}
85 changes: 0 additions & 85 deletions docs/Control/Monad/Eff.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/Control/Monad/Eff/Class.md

This file was deleted.

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

This file was deleted.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"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"
},
"devDependencies": {
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"pulp": "^4.0.1",
"rimraf": "^2.4.1"
"jscs": "^2.8.0",
"jshint": "^2.9.1",
"pulp": "^8.0.0",
"rimraf": "^2.5.0"
}
}
3 changes: 1 addition & 2 deletions src/Control/Monad/Eff.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* global exports */
"use strict";

// module Control.Monad.Eff

exports.returnE = function (a) {
exports.pureE = function (a) {
return function () {
return a;
};
Expand Down
65 changes: 39 additions & 26 deletions src/Control/Monad/Eff.purs
Original file line number Diff line number Diff line change
@@ -1,64 +1,77 @@
module Control.Monad.Eff
( Eff()
, Pure()
( Eff
, Pure
, runPure
, untilE, whileE, forE, foreachE
) where

import Prelude
import Control.Applicative (class Applicative, liftA1)
import Control.Apply (class Apply)
import Control.Bind (class Bind)
import Control.Monad (class Monad, ap)

import Data.Functor (class Functor)
import Data.Unit (Unit)

-- | The `Eff` type constructor is used to represent _native_ effects.
-- |
-- | See [Handling Native Effects with the Eff Monad](http://www.purescript.org/learn/eff/) for more details.
-- | See [Handling Native Effects with the Eff Monad](http://www.purescript.org/learn/eff/)
-- | for more details.
-- |
-- | The first type parameter is a row of effects which represents the contexts in which a computation can be run, and the second type parameter is the return type.
-- | The first type parameter is a row of effects which represents the contexts
-- | in which a computation can be run, and the second type parameter is the
-- | return type.
foreign import data Eff :: # ! -> * -> *

foreign import returnE :: forall e a. a -> Eff e a

foreign import bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b

-- | The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled.
-- |
-- | The `runPure` function can be used to run pure computations and obtain their result.
type Pure a = Eff () a

-- | Run a pure computation and return its result.
foreign import runPure :: forall a. Pure a -> a

instance functorEff :: Functor (Eff e) where
map = liftA1

instance applyEff :: Apply (Eff e) where
apply = ap

instance applicativeEff :: Applicative (Eff e) where
pure = returnE
pure = pureE

foreign import pureE :: forall e a. a -> Eff e a

instance bindEff :: Bind (Eff e) where
bind = bindE

foreign import bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b

instance monadEff :: Monad (Eff e)

-- | The `Pure` type synonym represents _pure_ computations, i.e. ones in which
-- | all effects have been handled.
-- |
-- | The `runPure` function can be used to run pure computations and obtain
-- | their result.
type Pure a = Eff () a

-- | Run a pure computation and return its result.
foreign import runPure :: forall a. Pure a -> a

-- | Loop until a condition becomes `true`.
-- |
-- | `untilE b` is an effectful computation which repeatedly runs the effectful computation `b`,
-- | until its return value is `true`.
-- | `untilE b` is an effectful computation which repeatedly runs the effectful
-- | computation `b`, until its return value is `true`.
foreign import untilE :: forall e. Eff e Boolean -> Eff e Unit

-- | Loop while a condition is `true`.
-- |
-- | `whileE b m` is effectful computation which runs the effectful computation `b`. If its result is
-- | `true`, it runs the effectful computation `m` and loops. If not, the computation ends.
-- | `whileE b m` is effectful computation which runs the effectful computation
-- | `b`. If its result is `true`, it runs the effectful computation `m` and
-- | loops. If not, the computation ends.
foreign import whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit

-- | Loop over a consecutive collection of numbers.
-- |
-- | `forE lo hi f` runs the computation returned by the function `f` for each of the inputs
-- | between `lo` (inclusive) and `hi` (exclusive).
foreign import forE :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
-- | `forE lo hi f` runs the computation returned by the function `f` for each
-- | of the inputs between `lo` (inclusive) and `hi` (exclusive).
foreign import forE :: forall e. Int -> Int -> (Int -> Eff e Unit) -> Eff e Unit

-- | Loop over an array of values.
-- |
-- | `foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`.
-- | `foreach xs f` runs the computation returned by the function `f` for each
-- | of the inputs `xs`.
foreign import foreachE :: forall e a. Array a -> (a -> Eff e Unit) -> Eff e Unit
Loading

0 comments on commit ce2fa05

Please sign in to comment.