Skip to content

Commit 36ca3b2

Browse files
authored
Merge pull request #34 from purescript/compiler/0.12
Updates for 0.12
2 parents 2e8974a + e427691 commit 36ca3b2

File tree

5 files changed

+49
-58
lines changed

5 files changed

+49
-58
lines changed

LICENSE

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
The MIT License (MIT)
1+
Copyright 2018 PureScript
22

3-
Copyright (c) 2016 Phil Freeman
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
45

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of
6-
this software and associated documentation files (the "Software"), to deal in
7-
the Software without restriction, including without limitation the rights to
8-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9-
the Software, and to permit persons to whom the Software is furnished to do so,
10-
subject to the following conditions:
6+
1. Redistributions of source code must retain the above copyright notice, this
7+
list of conditions and the following disclaimer.
118

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
9+
2. Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation and/or
11+
other materials provided with the distribution.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13+
3. Neither the name of the copyright holder nor the names of its contributors
14+
may be used to endorse or promote products derived from this software without
15+
specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bower.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "purescript-nonempty",
33
"homepage": "https://github.com/purescript/purescript-nonempty",
4-
"description": "A generic non-empty data structure",
5-
"license": "MIT",
4+
"license": "BSD-3-Clause",
65
"repository": {
76
"type": "git",
87
"url": "git://github.com/purescript/purescript-nonempty.git"
@@ -17,12 +16,15 @@
1716
"package.json"
1817
],
1918
"dependencies": {
20-
"purescript-foldable-traversable": "^3.4.0",
21-
"purescript-prelude": "^3.0.0",
22-
"purescript-unfoldable": "^3.2.0"
19+
"purescript-control": "^4.0.0",
20+
"purescript-foldable-traversable": "^4.0.0",
21+
"purescript-maybe": "^4.0.0",
22+
"purescript-prelude": "^4.0.0",
23+
"purescript-tuples": "^5.0.0",
24+
"purescript-unfoldable": "^4.0.0"
2325
},
2426
"devDependencies": {
25-
"purescript-assert": "^3.0.0",
26-
"purescript-console": "^3.0.0"
27+
"purescript-assert": "^4.0.0",
28+
"purescript-console": "^4.0.0"
2729
}
2830
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^10.0.4",
10-
"purescript-psa": "^0.5.0-rc.1",
11-
"rimraf": "^2.6.1"
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1212
}
1313
}

src/Data/NonEmpty.purs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ module Data.NonEmpty
55
, singleton
66
, (:|)
77
, foldl1
8-
, foldMap1
9-
, fold1
108
, fromNonEmpty
119
, oneOf
1210
, head
@@ -18,13 +16,13 @@ import Prelude
1816
import Control.Alt ((<|>))
1917
import Control.Alternative (class Alternative)
2018
import Control.Plus (class Plus, empty)
21-
import Data.Eq (class Eq1, eq1)
19+
import Data.Eq (class Eq1)
2220
import Data.Foldable (class Foldable, foldl, foldr, foldMap)
2321
import Data.FoldableWithIndex (class FoldableWithIndex, foldMapWithIndex, foldlWithIndex, foldrWithIndex)
2422
import Data.FunctorWithIndex (class FunctorWithIndex, mapWithIndex)
2523
import Data.Maybe (Maybe(..))
26-
import Data.Ord (class Ord1, compare1)
27-
import Data.Semigroup.Foldable as F1
24+
import Data.Ord (class Ord1)
25+
import Data.Semigroup.Foldable (class Foldable1, foldMap1)
2826
import Data.Traversable (class Traversable, traverse, sequence)
2927
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
3028
import Data.Tuple (uncurry)
@@ -52,14 +50,6 @@ singleton a = a :| empty
5250
foldl1 :: forall f a. Foldable f => (a -> a -> a) -> NonEmpty f a -> a
5351
foldl1 f (a :| fa) = foldl f a fa
5452

55-
-- | Fold a non-empty structure, collecting results in a `Semigroup`.
56-
foldMap1 :: forall f a s. Semigroup s => Foldable f => (a -> s) -> NonEmpty f a -> s
57-
foldMap1 = F1.foldMap1
58-
59-
-- | Fold a non-empty structure.
60-
fold1 :: forall f s. Semigroup s => Foldable f => NonEmpty f s -> s
61-
fold1 = F1.fold1
62-
6353
fromNonEmpty :: forall f a r. (a -> f a -> r) -> NonEmpty f a -> r
6454
fromNonEmpty f (a :| fa) = a `f` fa
6555

@@ -77,23 +67,15 @@ tail (_ :| xs) = xs
7767
instance showNonEmpty :: (Show a, Show (f a)) => Show (NonEmpty f a) where
7868
show (a :| fa) = "(NonEmpty " <> show a <> " " <> show fa <> ")"
7969

80-
instance eqNonEmpty :: (Eq1 f, Eq a) => Eq (NonEmpty f a) where
81-
eq = eq1
70+
derive instance eqNonEmpty :: (Eq1 f, Eq a) => Eq (NonEmpty f a)
8271

83-
instance eq1NonEmpty :: Eq1 f => Eq1 (NonEmpty f) where
84-
eq1 (NonEmpty a fa) (NonEmpty b fb) = a == b && fa `eq1` fb
72+
derive instance eq1NonEmpty :: Eq1 f => Eq1 (NonEmpty f)
8573

86-
instance ordNonEmpty :: (Ord1 f, Ord a) => Ord (NonEmpty f a) where
87-
compare = compare1
74+
derive instance ordNonEmpty :: (Ord1 f, Ord a) => Ord (NonEmpty f a)
8875

89-
instance ord1NonEmpty :: Ord1 f => Ord1 (NonEmpty f) where
90-
compare1 (NonEmpty a fa) (NonEmpty b fb) =
91-
case compare a b of
92-
EQ -> compare1 fa fb
93-
c -> c
76+
derive instance ord1NonEmpty :: Ord1 f => Ord1 (NonEmpty f)
9477

95-
instance functorNonEmpty :: Functor f => Functor (NonEmpty f) where
96-
map f (a :| fa) = f a :| map f fa
78+
derive instance functorNonEmpty :: Functor f => Functor (NonEmpty f)
9779

9880
instance functorWithIndex
9981
:: FunctorWithIndex i f
@@ -122,8 +104,8 @@ instance traversableWithIndexNonEmpty
122104
traverseWithIndex f (a :| fa) =
123105
NonEmpty <$> f Nothing a <*> traverseWithIndex (f <<< Just) fa
124106

125-
instance foldable1NonEmpty :: Foldable f => F1.Foldable1 (NonEmpty f) where
126-
fold1 = foldMap1 id
107+
instance foldable1NonEmpty :: Foldable f => Foldable1 (NonEmpty f) where
108+
fold1 = foldMap1 identity
127109
foldMap1 f (a :| fa) = foldl (\s a1 -> s <> f a1) (f a) fa
128110

129111
instance unfoldable1NonEmpty :: Unfoldable f => Unfoldable1 (NonEmpty f) where

test/Main.purs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff)
65
import Data.Foldable (fold, foldl)
76
import Data.Maybe (Maybe(..))
8-
import Data.NonEmpty (NonEmpty(), (:|), fold1, foldl1, oneOf, head, tail, singleton)
7+
import Data.NonEmpty (NonEmpty, (:|), foldl1, oneOf, head, tail, singleton)
8+
import Data.Semigroup.Foldable (fold1)
99
import Data.Unfoldable1 as U1
10-
import Test.Assert (ASSERT, assert)
10+
import Effect (Effect)
11+
import Test.Assert (assert)
1112

1213
type AtLeastTwo f a = NonEmpty (NonEmpty f) a
1314

1415
second :: forall f a. AtLeastTwo f a -> a
1516
second = tail >>> head
1617

17-
main :: Eff (assert :: ASSERT) Unit
18+
main :: Effect Unit
1819
main = do
1920
assert $ singleton 0 == 0 :| []
2021
assert $ 0 :| Nothing /= 0 :| Just 1

0 commit comments

Comments
 (0)