Skip to content

Commit

Permalink
Updates for 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
kritzcreek committed May 24, 2018
1 parent c56f471 commit 8323b4a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
@@ -1,15 +1,21 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
- npm install bower -g
- 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 --production
script:
- bower install --production
- npm run -s build
- bower install
- npm -s test
- npm run -s test
after_success:
- >-
test $TRAVIS_TAG &&
Expand Down
25 changes: 23 additions & 2 deletions bower.json
Expand Up @@ -12,7 +12,6 @@
"url": "git://github.com/purescript-contrib/purescript-profunctor-lenses.git"
},
"dependencies": {
"purescript-const": "#compiler/0.12",
"purescript-functors": "#compiler/0.12",
"purescript-foldable-traversable": "#compiler/0.12",
"purescript-identity": "#compiler/0.12",
Expand All @@ -23,7 +22,29 @@
"purescript-transformers": "#compiler/0.12",
"purescript-record": "#compiler/0.12"
},
"dependencies": {
"purescript-arrays": "^4.0.0",
"purescript-bifunctors": "^4.0.0",
"purescript-const": "^4.0.0",
"purescript-control": "^4.0.0",
"purescript-distributive": "^4.0.0",
"purescript-either": "^4.0.0",
"purescript-foldable-traversable": "^4.0.0",
"purescript-foreign-object": "^1.0.0",
"purescript-functors": "^3.0.0",
"purescript-identity": "^4.0.0",
"purescript-lists": "^5.0.0",
"purescript-maybe": "^4.0.0",
"purescript-newtype": "^3.0.0",
"purescript-ordered-collections": "^1.0.0",
"purescript-partial": "^2.0.0",
"purescript-prelude": "^4.0.0",
"purescript-profunctor": "^4.0.0",
"purescript-record": "^1.0.0",
"purescript-transformers": "^4.0.0",
"purescript-tuples": "^5.0.0"
},
"devDependencies": {
"purescript-console": "#compiler/0.12"
"purescript-console": "^4.0.0"
}
}
4 changes: 2 additions & 2 deletions src/Data/Lens/Indexed.purs
Expand Up @@ -9,7 +9,7 @@ import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Setter ((%~))
import Data.Lens.Types (wander, Optic, IndexedOptic, Indexed(..), Traversal, IndexedTraversal)
import Data.Newtype (unwrap)
import Data.Profunctor (class Profunctor, dimap, lmap)
import Data.Profunctor (class Profunctor, dimap, lcmap)
import Data.Profunctor.Star (Star(..))
import Data.Profunctor.Strong (first)
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
Expand All @@ -33,7 +33,7 @@ asIndex l = l <<< Indexed <<< dimap fst identity
-- | Remap the index.
reindexed :: forall p i j r a b . Profunctor p =>
(i -> j) -> (Indexed p i a b -> r) -> Indexed p j a b -> r
reindexed ij = (_ <<< _Newtype %~ lmap (first ij))
reindexed ij = (_ <<< _Newtype %~ lcmap (first ij))

-- | Converts a `lens`-like indexed traversal to an `IndexedTraversal`.
iwander
Expand Down
10 changes: 5 additions & 5 deletions src/Data/Lens/Internal/Indexed.purs
Expand Up @@ -6,7 +6,7 @@ import Prelude
import Data.Either (Either(..), either)
import Data.Lens.Internal.Wander (class Wander, wander)
import Data.Newtype (class Newtype)
import Data.Profunctor (class Profunctor, lmap, dimap)
import Data.Profunctor (class Profunctor, lcmap, dimap)
import Data.Profunctor.Choice (class Choice, right, left)
import Data.Profunctor.Strong (class Strong, first, second)
import Data.Tuple (Tuple(..))
Expand All @@ -21,15 +21,15 @@ instance profunctorIndexed :: Profunctor p => Profunctor (Indexed p i) where

instance strongIndexed :: Strong p => Strong (Indexed p i) where
first (Indexed p) =
Indexed $ lmap (\(Tuple i (Tuple a c)) -> (Tuple (Tuple i a) c)) $ first p
Indexed $ lcmap (\(Tuple i (Tuple a c)) -> (Tuple (Tuple i a) c)) $ first p
second (Indexed p) =
Indexed $ lmap (\(Tuple i (Tuple c a)) -> (Tuple c (Tuple i a))) $ second p
Indexed $ lcmap (\(Tuple i (Tuple c a)) -> (Tuple c (Tuple i a))) $ second p

instance choiceIndexed :: Choice p => Choice (Indexed p i) where
left (Indexed p) =
Indexed $ lmap (\(Tuple i ac) -> either (Left <<< Tuple i) Right ac) $ left p
Indexed $ lcmap (\(Tuple i ac) -> either (Left <<< Tuple i) Right ac) $ left p
right (Indexed p) =
Indexed $ lmap (\(Tuple i ac) -> either Left (Right <<< Tuple i) ac) $ right p
Indexed $ lcmap (\(Tuple i ac) -> either Left (Right <<< Tuple i) ac) $ right p

instance wanderIndexed :: Wander p => Wander (Indexed p i) where
wander trav (Indexed p) =
Expand Down
10 changes: 5 additions & 5 deletions src/Data/Lens/Internal/Market.purs
Expand Up @@ -3,7 +3,7 @@ module Data.Lens.Internal.Market where

import Prelude

import Data.Bifunctor as BF
import Data.Bifunctor (lmap)
import Data.Either (Either(..), either)
import Data.Profunctor (class Profunctor)
import Data.Profunctor.Choice (class Choice)
Expand All @@ -12,13 +12,13 @@ import Data.Profunctor.Choice (class Choice)
data Market a b s t = Market (b -> t) (s -> Either t a)

instance functorMarket :: Functor (Market a b s) where
map f (Market a b) = Market (f <<< a) (BF.lmap f <<< b)
map f (Market a b) = Market (f <<< a) (lmap f <<< b)

instance profunctorMarket :: Profunctor (Market a b) where
dimap f g (Market a b) = Market (g <<< a) (BF.lmap g <<< b <<< f)
dimap f g (Market a b) = Market (g <<< a) (lmap g <<< b <<< f)

instance choiceMarket :: Choice (Market a b) where
left (Market x y) =
Market (Left <<< x) (either (BF.lmap Left <<< y) (Left <<< Right))
Market (Left <<< x) (either (lmap Left <<< y) (Left <<< Right))
right (Market x y) =
Market (Right <<< x) (either (Left <<< Left) (BF.lmap Right <<< y))
Market (Right <<< x) (either (Left <<< Left) (lmap Right <<< y))
4 changes: 2 additions & 2 deletions src/Data/Lens/Setter.purs
Expand Up @@ -97,11 +97,11 @@ setJust p = set p <<< Just

-- | Set the foci of a `Setter` in a monadic state to a constant value.
assign :: forall s a b m. MonadState s m => Setter s s a b -> b -> m Unit
assign p b = modify (set p b)
assign p b = void (modify (set p b))

-- | Modify the foci of a `Setter` in a monadic state.
modifying :: forall s a b m. MonadState s m => Setter s s a b -> (a -> b) -> m Unit
modifying p f = modify (over p f)
modifying p f = void (modify (over p f))

addModifying :: forall s a m. MonadState s m => Semiring a => Setter' s a -> a -> m Unit
addModifying p = modifying p <<< add
Expand Down

0 comments on commit 8323b4a

Please sign in to comment.