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
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.psci*
bower_components/
output/

/.*
!/.gitignore
!/.jscsrc
!/.jshintrc
!/.travis.yml
/bower_components/
/node_modules/
/output/
17 changes: 17 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"preset": "grunt",
"disallowSpacesInFunctionExpression": null,
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": null,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInsideObjectBrackets": null,
"requireSpacesInsideObjectBrackets": "all",
"validateQuoteMarks": "\"",
"requireCurlyBraces": null
}
19 changes: 19 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bitwise": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"funcscope": true,
"futurehostile": true,
"strict": "global",
"latedef": true,
"noarg": true,
"nocomma": true,
"nonew": true,
"notypeof": true,
"singleGroups": true,
"undef": true,
"unused": true,
"eqnull": true,
"predef": ["exports"]
}
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
install:
- npm install -g bower
- npm install
script:
- bower install --production
- npm run -s build
- bower install
- npm -s test
after_success:
- >-
test $TRAVIS_TAG &&
echo $GITHUB_TOKEN | pulp login &&
echo y | pulp publish --no-push
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# purescript-nullable

[![Latest release](http://img.shields.io/bower/v/purescript-nullable.svg)](https://github.com/purescript-contrib/purescript-nullable/releases)
[![Build Status](https://travis-ci.org/purescript-contrib/purescript-nullable.svg?branch=master)](https://travis-ci.org/purescript-contrib/purescript-nullable)
[![Maintainer: paf31](https://img.shields.io/badge/maintainer-paf31-lightgrey.svg)](http://github.com/paf31)

A library for dealing with null values in foreign libraries.
Expand Down
14 changes: 9 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
"node_modules",
"output",
"bower.json",
"package.json"
],
"dependencies": {
"purescript-maybe": "^1.0.0-rc.1",
"purescript-functions": "^1.0.0-rc.1"
"purescript-maybe": "^2.0.0",
"purescript-functions": "^2.0.0"
},
"repository": {
"type": "git",
"url": "git://github.com/paf31/purescript-nullable.git"
},
"devDependencies": {
"purescript-console": "^2.0.0"
}
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src && jscs src && pulp build --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"jscs": "^2.8.0",
"jshint": "^2.9.1",
"pulp": "^9.0.1",
"purescript-psa": "^0.3.9",
"purescript": "^0.10.1",
"rimraf": "^2.5.0"
}
}
9 changes: 4 additions & 5 deletions src/Data/Nullable.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* global exports */
"use strict";

exports["null"] = null;

exports.nullable = function(a, r, f) {
return a == null ? r : f(a);
exports.nullable = function (a, r, f) {
return a == null ? r : f(a);
};

exports.notNull = function(x) {
return x;
exports.notNull = function (x) {
return x;
};
10 changes: 4 additions & 6 deletions src/Data/Nullable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
-- | using the FFI.

module Data.Nullable
( Nullable()
( Nullable
, toMaybe
, toNullable
) where

import Prelude (class Ord, class Eq, class Show, compare, eq, show)
import Prelude

import Data.Function (on)
import Data.Function.Uncurried (Fn3, runFn3)
Expand Down Expand Up @@ -35,10 +35,8 @@ toNullable = maybe null notNull
toMaybe :: forall a. Nullable a -> Maybe a
toMaybe n = runFn3 nullable n Nothing Just

instance showNullable :: (Show a) => Show (Nullable a) where
show n = case toMaybe n of
Nothing -> "null"
Just a -> show a
instance showNullable :: Show a => Show (Nullable a) where
show = maybe "null" show <<< toMaybe

instance eqNullable :: (Eq a) => Eq (Nullable a) where
eq = eq `on` toMaybe
Expand Down