This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from purescript/0.8-updates
Updates for PureScript 0.8
- Loading branch information
Showing
15 changed files
with
93 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,3 @@ | |
/bower_components/ | ||
/node_modules/ | ||
/output/ | ||
/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.