Skip to content

Updates for PureScript 0.8 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2016
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
5 changes: 5 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"preset": "grunt",
"disallowSpacesInFunctionExpression": null,
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": null,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
Expand Down
5 changes: 3 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"freeze": true,
"funcscope": true,
"futurehostile": true,
"globalstrict": true,
"strict": "global",
"latedef": true,
"maxparams": 1,
"noarg": true,
Expand All @@ -15,5 +15,6 @@
"singleGroups": true,
"undef": true,
"unused": true,
"eqnull": true
"eqnull": true,
"predef": ["exports"]
}
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
language: node_js
sudo: false
node_js:
- 0.10
sudo: required
dist: trusty
node_js: 5
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 -g bower
- npm install
- bower install
script:
- npm run build
after_success:
- >-
test $TRAVIS_TAG &&
psc-publish > .pursuit.json &&
curl -X POST http://pursuit.purescript.org/packages \
-d @.pursuit.json \
-H 'Accept: application/json' \
-H "Authorization: token ${GITHUB_TOKEN}"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Call-by-need values.
bower install purescript-lazy
```

## Module documentation
## Documentation

- [Data.Lazy](docs/Data/Lazy.md)
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-console).
3 changes: 0 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"John A. De Goes <john@degoes.net>"
],
"description": "Call-by-need values",
"keywords": [
"purescript"
],
"license": "MIT",
"repository": {
"type": "git",
Expand Down
63 changes: 0 additions & 63 deletions docs/Data/Lazy.md

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"private": true,
"scripts": {
"postinstall": "pulp dep install",
"build": "jshint src && jscs src && pulp build && rimraf docs && pulp docs"
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src && jscs src && pulp build"
},
"devDependencies": {
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"pulp": "^4.0.2",
"rimraf": "^2.4.1"
"jscs": "^2.8.0",
"jshint": "^2.9.1",
"pulp": "^8.1.0",
"rimraf": "^2.5.0"
}
}
2 changes: 1 addition & 1 deletion src/Data/Lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

exports.defer = function () {

function Defer (thunk) {
function Defer(thunk) {
if (this instanceof Defer) {
this.thunk = thunk;
return this;
Expand Down
32 changes: 18 additions & 14 deletions src/Data/Lazy.purs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-- | A monad for lazily-computed values

module Data.Lazy where

import Prelude (class Show, class Monad, class Bind, class Applicative, class Apply, class Functor, class BooleanAlgebra, class Semigroup, class BoundedOrd, class Bounded, class Ord, class Eq, class Num, class DivisionRing, class ModuloSemiring, class Ring, class Semiring, Unit, unit, show, append, ($), (<<<), not, (<$>), (<*>), disj, conj, (<>), bottom, top, compare, (==), mod, (/), (-), one, (*), zero, (+))
import Prelude

import Control.Comonad (class Comonad)
import Control.Extend (class Extend)
import Data.Monoid (class Monoid, mempty)
import Control.Lazy as CL

import Data.HeytingAlgebra (implies, ff, tt)
import Data.Monoid (class Monoid, mempty)

-- | `Lazy a` represents lazily-computed values of type `a`.
-- |
-- | A lazy value is computed at most once - the result is saved
Expand Down Expand Up @@ -36,13 +36,14 @@ instance semiringLazy :: (Semiring a) => Semiring (Lazy a) where
instance ringLazy :: (Ring a) => Ring (Lazy a) where
sub a b = defer \_ -> force a - force b

instance moduloSemiringLazy :: (ModuloSemiring a) => ModuloSemiring (Lazy a) where
instance commutativeRingLazy :: (CommutativeRing a) => CommutativeRing (Lazy a)

instance euclideanRingLazy :: (EuclideanRing a) => EuclideanRing (Lazy a) where
degree = degree <<< force
div a b = defer \_ -> force a / force b
mod a b = defer \_ -> force a `mod` force b

instance divisionRingLazy :: (DivisionRing a) => DivisionRing (Lazy a)

instance numLazy :: (Num a) => Num (Lazy a)
instance fieldLazy :: (Field a) => Field (Lazy a)

instance eqLazy :: (Eq a) => Eq (Lazy a) where
eq x y = (force x) == (force y)
Expand All @@ -54,30 +55,33 @@ instance boundedLazy :: (Bounded a) => Bounded (Lazy a) where
top = defer \_ -> top
bottom = defer \_ -> bottom

instance boundedOrdLazy :: (BoundedOrd a) => BoundedOrd (Lazy a)

instance semigroupLazy :: (Semigroup a) => Semigroup (Lazy a) where
append a b = defer \_ -> force a <> force b

instance monoidLazy :: (Monoid a) => Monoid (Lazy a) where
mempty = defer \_ -> mempty

instance booleanAlgebraLazy :: (BooleanAlgebra a) => BooleanAlgebra (Lazy a) where
instance heytingAlgebraLazy :: (HeytingAlgebra a) => HeytingAlgebra (Lazy a) where
ff = defer \_ -> ff
tt = defer \_ -> tt
implies a b = implies <$> a <*> b
conj a b = conj <$> a <*> b
disj a b = disj <$> a <*> b
not a = not <$> a

instance booleanAlgebraLazy :: (BooleanAlgebra a) => BooleanAlgebra (Lazy a)

instance functorLazy :: Functor Lazy where
map f l = defer \_ -> f (force l)

instance applyLazy :: Apply Lazy where
apply f x = defer \_ -> force f $ force x
apply f x = defer \_ -> force f (force x)

instance applicativeLazy :: Applicative Lazy where
pure a = defer \_ -> a

instance bindLazy :: Bind Lazy where
bind l f = defer \_ -> force <<< f <<< force $ l
bind l f = defer \_ -> force $ f (force l)

instance monadLazy :: Monad Lazy

Expand All @@ -88,7 +92,7 @@ instance comonadLazy :: Comonad Lazy where
extract = force

instance showLazy :: (Show a) => Show (Lazy a) where
show x = "Lazy " `append` show (force x)
show x = "(defer \\_ -> " <> show (force x) <> ")"

instance lazyLazy :: CL.Lazy (Lazy a) where
defer f = defer \_ -> force (f unit)