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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.*
!/.gitignore
!/.travis.yml
/bower_components/
/node_modules/
/output/
Expand Down
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
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 bower gulp -g
- npm install && bower install
script:
- gulp
33 changes: 0 additions & 33 deletions Gruntfile.js

This file was deleted.

116 changes: 13 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,119 +1,29 @@
# Module Documentation
# purescript-integers

## Module Data.Int
[![Build Status](https://travis-ci.org/purescript/purescript-integers.svg?branch=master)](https://travis-ci.org/purescript/purescript-integers)

#### `Int`

``` purescript
newtype Int
```
This library provides a 32-bit `Int` type for PureScript along with corresponding bitwise operations.

## Installation

#### `fromNumber`

``` purescript
fromNumber :: Number -> Int
```

Creates an `Int` from a `Number` value. If the value is not already an
integer it is rounded down.

#### `toNumber`

``` purescript
toNumber :: Int -> Number
bower install purescript-integers
```

## Overview

#### `showInt`
Integers are constructed from the standard `Number` by using the `fromNumber` function:

``` purescript
instance showInt :: Show Int
ten = fromNumber 10
```

See the [module documentation](docs/MODULE.md) for more details on the behaviour of `fromNumber`.

#### `eqInt`

``` purescript
instance eqInt :: Eq Int
```


#### `ordInt`

``` purescript
instance ordInt :: Ord Int
```


#### `semiringInt`

``` purescript
instance semiringInt :: Semiring Int
```


#### `moduloSemiringInt`

``` purescript
instance moduloSemiringInt :: ModuloSemiring Int
```


#### `ringInt`

``` purescript
instance ringInt :: Ring Int
```

A `Semiring Int` instance is also provided so `zero` and `one` can be used for the equivalent integer values.

As values outside of the range -2,147,483,648 to 2,147,483,648 will overflow and wrap around, the `Int` type does not _strictly_ obey the laws for `Semiring` and `Ring`.

## Module Data.Int.Bits
## Module documentation

#### `(.&.)`

``` purescript
(.&.) :: Int -> Int -> Int
```


#### `(.|.)`

``` purescript
(.|.) :: Int -> Int -> Int
```


#### `(.^.)`

``` purescript
(.^.) :: Int -> Int -> Int
```


#### `shl`

``` purescript
shl :: Int -> Int -> Int
```


#### `shr`

``` purescript
shr :: Int -> Int -> Int
```


#### `zshr`

``` purescript
zshr :: Int -> Int -> Int
```


#### `complement`

``` purescript
complement :: Int -> Int
```
[`docs/MODULE.md`](docs/MODULE.md)
9 changes: 5 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
"bower_components",
"node_modules",
"output",
"tests",
"tmp",
"bower.json",
"Gruntfile.js",
"gulpfile.js",
"package.json"
]
],
"dependencies": {
"purescript-prelude": "~0.1.0"
}
}
154 changes: 154 additions & 0 deletions docs/MODULE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Module Documentation

## Module Data.Int

#### `Int`

``` purescript
newtype Int
```

A 32 bit integer.

#### `fromNumber`

``` purescript
fromNumber :: Number -> Int
```

Creates an `Int` from a `Number` value. If the value is not already an
integer it is rounded towards zero (so both `0.9` and `-0.9` will become
`Int 0`).

#### `toNumber`

``` purescript
toNumber :: Int -> Number
```

Converts an `Int` value back into a `Number`. Any `Int` is a valid `Number`
so there is no loss of precision with this function.

#### `toString`

``` purescript
toString :: Int -> String
```

Creates a `String` value from an `Int`. This differs from the `Show`
instance as, for example, an `Int` value of 42 will be rendered as `"42"`
by `toString`, whereas with `show` it would be rendered as
`"fromNumber 42"`.

#### `showInt`

``` purescript
instance showInt :: Show Int
```


#### `eqInt`

``` purescript
instance eqInt :: Eq Int
```


#### `ordInt`

``` purescript
instance ordInt :: Ord Int
```


#### `semiringInt`

``` purescript
instance semiringInt :: Semiring Int
```

The `Int` type does not strictly obey the `Semiring` laws due to the
wrapping behaviour with values smaller than -2,147,483,648 or larger than
2,147,483,648.

#### `moduloSemiringInt`

``` purescript
instance moduloSemiringInt :: ModuloSemiring Int
```


#### `ringInt`

``` purescript
instance ringInt :: Ring Int
```

The `Int` type does not strictly obey the `Ring` laws due to the
wrapping behaviour with values smaller than -2,147,483,648 or larger than
2,147,483,648.


## Module Data.Int.Bits


This module defines bitwise operations for the `Int` type.

#### `(.&.)`

``` purescript
(.&.) :: Int -> Int -> Int
```

Bitwise AND.

#### `(.|.)`

``` purescript
(.|.) :: Int -> Int -> Int
```

Bitwise OR.

#### `(.^.)`

``` purescript
(.^.) :: Int -> Int -> Int
```

Bitwise XOR.

#### `shl`

``` purescript
shl :: Int -> Int -> Int
```

Bitwise shift left.

#### `shr`

``` purescript
shr :: Int -> Int -> Int
```

Bitwise shift right.

#### `zshr`

``` purescript
zshr :: Int -> Int -> Int
```

Bitwise zero-fill shift right.

#### `complement`

``` purescript
complement :: Int -> Int
```

Bitwise NOT.



38 changes: 38 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";

var gulp = require("gulp");
var plumber = require("gulp-plumber");
var purescript = require("gulp-purescript");
var jsvalidate = require("gulp-jsvalidate");

var paths = [
"src/**/*.purs",
"bower_components/purescript-*/src/**/*.purs"
];

gulp.task("make", function() {
return gulp.src(paths)
.pipe(plumber())
.pipe(purescript.pscMake());
});

gulp.task("jsvalidate", ["make"], function () {
return gulp.src("output/**/*.js")
.pipe(plumber())
.pipe(jsvalidate());
});

gulp.task("docs", function () {
return gulp.src("src/**/*.purs")
.pipe(plumber())
.pipe(purescript.pscDocs())
.pipe(gulp.dest("docs/MODULE.md"));
});

gulp.task("dotpsci", function () {
return gulp.src(paths)
.pipe(plumber())
.pipe(purescript.dotPsci());
});

gulp.task("default", ["jsvalidate", "docs", "dotpsci"]);
Loading