Skip to content

Commit

Permalink
Merge pull request #21 from purescript/ps-0.11
Browse files Browse the repository at this point in the history
Update for PureScript 0.11
  • Loading branch information
garyb authored Mar 26, 2017
2 parents ba3d96a + c3c023b commit b4cff5e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"package.json"
],
"dependencies": {
"purescript-distributive": "^2.0.0",
"purescript-either": "^2.0.0",
"purescript-tuples": "^3.0.0"
"purescript-distributive": "^3.0.0",
"purescript-either": "^3.0.0",
"purescript-tuples": "^4.0.0"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "pulp build --censor-lib --strict"
"build": "pulp build -- --censor-lib --strict"
},
"devDependencies": {
"pulp": "^9.0.1",
"purescript-psa": "^0.3.9",
"rimraf": "^2.5.0"
"pulp": "^10.0.4",
"purescript-psa": "^0.5.0-rc.1",
"rimraf": "^2.6.1"
}
}
6 changes: 3 additions & 3 deletions src/Data/Profunctor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ rmap :: forall a b c p. Profunctor p => (b -> c) -> p a b -> p a c
rmap b2c = dimap id b2c

-- | Lift a pure function into any `Profunctor` which is also a `Category`.
arr :: forall a b p. (Category p, Profunctor p) => (a -> b) -> p a b
arr :: forall a b p. Category p => Profunctor p => (a -> b) -> p a b
arr f = rmap f id

unwrapIso :: forall p t a. (Profunctor p, Newtype t a) => p t t -> p a a
unwrapIso :: forall p t a. Profunctor p => Newtype t a => p t t -> p a a
unwrapIso = dimap wrap unwrap

wrapIso :: forall p t a. (Profunctor p, Newtype t a) => (t -> a) -> p a a -> p t t
wrapIso :: forall p t a. Profunctor p => Newtype t a => (t -> a) -> p a a -> p t t
wrapIso _ = dimap unwrap wrap

instance profunctorFn :: Profunctor (->) where
Expand Down
16 changes: 14 additions & 2 deletions src/Data/Profunctor/Choice.purs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ instance choiceFn :: Choice (->) where
-- | We take two functions, `f` and `g`, and we transform them into a single function which
-- | takes an `Either`and maps `f` over the left side and `g` over the right side. Just like
-- | `bi-map` would do for the `bi-functor` instance of `Either`.
splitChoice :: forall p a b c d. (Category p, Choice p) => p a b -> p c d -> p (Either a c) (Either b d)
splitChoice
:: forall p a b c d
. Category p
=> Choice p
=> p a b
-> p c d
-> p (Either a c) (Either b d)
splitChoice l r = left l >>> right r

infixr 2 splitChoice as +++
Expand All @@ -65,7 +71,13 @@ infixr 2 splitChoice as +++
-- | whether the `Either` value is a `Left` or a `Right`.
-- | This allows us to bundle two different computations which both have the same result type into one
-- | function which will run the approriate computation based on the parameter supplied in the `Either` value.
fanin :: forall p a b c. (Category p, Choice p) => p a c -> p b c -> p (Either a b) c
fanin
:: forall p a b c
. Category p
=> Choice p
=> p a c
-> p b c
-> p (Either a b) c
fanin l r = (l +++ r) >>> join
where
join :: p (Either c c) c
Expand Down
16 changes: 14 additions & 2 deletions src/Data/Profunctor/Strong.purs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ instance strongFn :: Strong (->) where
-- | We take two functions, `f` and `g`, and we transform them into a single function which
-- | takes a `Tuple` and maps `f` over the first element and `g` over the second. Just like `bi-map`
-- | would do for the `bi-functor` instance of `Tuple`.
splitStrong :: forall p a b c d. (Category p, Strong p) => p a b -> p c d -> p (Tuple a c) (Tuple b d)
splitStrong
:: forall p a b c d
. Category p
=> Strong p
=> p a b
-> p c d
-> p (Tuple a c) (Tuple b d)
splitStrong l r = first l >>> second r

infixr 3 splitStrong as ***
Expand All @@ -62,7 +68,13 @@ infixr 3 splitStrong as ***
-- | single function which takes one parameter and returns a `Tuple` of the results of running
-- | `f` and `g` on the parameter, respectively. This allows us to run two parallel computations
-- | on the same input and return both results in a `Tuple`.
fanout :: forall p a b c. (Category p, Strong p) => p a b -> p a c -> p a (Tuple b c)
fanout
:: forall p a b c
. Category p
=> Strong p
=> p a b
-> p a c
-> p a (Tuple b c)
fanout l r = split >>> (l *** r)
where
split :: p a (Tuple a a)
Expand Down

0 comments on commit b4cff5e

Please sign in to comment.