Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
bower_components
output
.psci
.psci_modules
/.*
!/.gitignore
!/.travis.yml
/bower_components/
/node_modules/
/output/
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: node_js
sudo: false
node_js:
- 0.10
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
script:
- npm run build
8 changes: 8 additions & 0 deletions docs/Data/NonEmpty.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ instance foldableNonEmpty :: (Foldable f) => Foldable (NonEmpty f)
instance traversableNonEmpty :: (Traversable f) => Traversable (NonEmpty f)
```

#### `singleton`

``` purescript
singleton :: forall f a. (Plus f) => a -> NonEmpty f a
```

Create a non-empty structure with a single value.

#### `(:|)`

``` purescript
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"scripts": {
"postinstall": "pulp dep install",
"build": "pulp test && rimraf docs && pulp docs"
},
"devDependencies": {
"pulp": "^4.0.1",
"rimraf": "^2.4.1"
}
}
8 changes: 7 additions & 1 deletion src/Data/NonEmpty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module Data.NonEmpty
( NonEmpty(..)
, singleton
, (:|)
, foldl1
, foldMap1
Expand All @@ -13,8 +14,9 @@ module Data.NonEmpty

import Prelude

import Control.Alternative (Alternative)
import Control.Alt ((<|>))
import Control.Alternative (Alternative)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used by oneOf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops sorry.

import Control.Plus (Plus, empty)

import Data.Foldable (Foldable, foldl, foldr, foldMap)
import Data.Traversable (Traversable, traverse, sequence)
Expand All @@ -31,6 +33,10 @@ data NonEmpty f a = NonEmpty a (f a)

infix 5 :|

-- | Create a non-empty structure with a single value.
singleton :: forall f a. (Plus f) => a -> NonEmpty f a
singleton a = NonEmpty a empty

-- | An infix synonym for `NonEmpty`.
(:|) :: forall f a. a -> f a -> NonEmpty f a
(:|) = NonEmpty
Expand Down