Skip to content

Commit

Permalink
Merge pull request #13 from purescript-contrib/0.9-updates
Browse files Browse the repository at this point in the history
Updates for PureScript 0.9.1
  • Loading branch information
garyb committed Jun 2, 2016
2 parents 01f8ae3 + 495ed44 commit a4b2206
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 225 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/.*
!/.gitignore
!/.jscsrc
!/.jshintrc
!/.travis.yml
/bower_components/
/node_modules/
/output/
/tmp/
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: node_js
sudo: false
node_js:
- 0.12.7
dist: trusty
sudo: required
node_js: 6
install:
- npm install bower -g
- npm install -g bower
- npm install
- bower install
script:
- pulp build
- bower install --production
- npm run -s build
after_success:
- >-
test $TRAVIS_TAG &&
echo $GITHUB_TOKEN | pulp login &&
echo y | pulp publish --no-push
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# PureScript-Machines
# purescript-machines

This library helps you build finite state machines. Currently, there's an implementation for mealy machines with halting.
[![Latest release](http://img.shields.io/bower/v/purescript-machines.svg)](https://github.com/purescript-contrib/purescript-machines/releases)
[![Build Status](https://travis-ci.org/purescript-contrib/purescript-machines.svg?branch=master)](https://travis-ci.org/purescript-contrib/purescript-machines)

**Note**: If you need the ability to produce errors, consume from multiple input tapes, or guarantee resource cleanup, you should probably be using [PureScript Streams](http://github.com/purescript-contrib/purescript-streams) instead.
This library helps you build finite state machines. Currently, there's an implementation for Mealy machines with halting.

## Installation

This can be installed with Bower:

```shell
bower i purescript-machines
```

## Documentation

API docs can be found [here](docs/Data/Machine/Mealy.md).
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-machines).
16 changes: 7 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
},
"license": "MIT",
"dependencies": {
"purescript-eff": "~0.1.0",
"purescript-maybe": "~0.3.2",
"purescript-monoid": "~0.3.0",
"purescript-profunctor": "~0.3.0",
"purescript-tuples": "~0.4.0",
"purescript-arrays": "~0.4.0",
"purescript-arrows": "~0.6.0",
"purescript-prelude": "~0.1.0",
"purescript-lists": "~0.7.0"
"purescript-arrays": "^1.0.0",
"purescript-eff": "^1.0.0",
"purescript-lists": "^1.0.0",
"purescript-maybe": "^1.0.0",
"purescript-monoid": "^1.0.0",
"purescript-profunctor": "^1.0.0",
"purescript-tuples": "^1.0.0"
}
}
178 changes: 0 additions & 178 deletions docs/Data/Machine/Mealy.md

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "purescript-machines",
"description": "Mealy Machines in PureScript",
"license": "MIT",
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "psa \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" --censor-lib --strict"
},
"devDependencies": {
"pulp": "^4.4.0",
"purescript": "^0.7.4"
"purescript-psa": "^0.3.8",
"purescript": "^0.9.1-rc.1",
"rimraf": "^2.5.0"
}
}
41 changes: 21 additions & 20 deletions src/Data/Machine/Mealy.purs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Data.Machine.Mealy
( MealyT()
( MealyT
, runMealyT
, Step(..)
, Source()
, Sink()
, Source
, Sink
, source
, sink
, stepMealy
Expand All @@ -22,26 +22,27 @@ module Data.Machine.Mealy
, fromArray
, msplit
, interleave
, (>>-)
, when
, ifte
, wrapEffect
) where

import Prelude
import Control.Alt (Alt)
import Control.Alternative (Alternative)
import Control.Arrow (Arrow)
import Control.Bind (join)
import Control.Lazy (Lazy)
import Control.MonadPlus (MonadPlus)
import Control.Plus (Plus)
import Control.Monad.Eff.Class (MonadEff, liftEff)

import Control.Alt (class Alt)
import Control.Alternative (class Alternative)
import Control.Lazy (class Lazy)
import Control.Monad.Eff.Class (class MonadEff, liftEff)
import Control.MonadPlus (class MonadPlus)
import Control.MonadZero (class MonadZero)
import Control.Plus (class Plus)

import Data.Array ((!!), length)
import Data.List (List(..))
import Data.Maybe (Maybe(..))
import Data.Monoid (Monoid)
import Data.Profunctor (Profunctor, dimap)
import Data.Profunctor.Strong (Strong, first)
import Data.Monoid (class Monoid)
import Data.Profunctor (class Profunctor, dimap)
import Data.Profunctor.Strong (class Strong, first)
import Data.Tuple (Tuple(..), fst, snd, swap)

newtype MealyT f s a = MealyT (f (s -> f (Step f s a)))
Expand Down Expand Up @@ -149,8 +150,8 @@ ifte ma f mb = mealy $ \s -> let g Halt = stepMealy s mb

in stepMealy s ma >>= g

(>>-) :: forall f s a b. (Monad f) => MealyT f s a -> (a -> MealyT f s b) -> MealyT f s b
(>>-) ma f = ifte ma f halt
when :: forall f s a b. (Monad f) => MealyT f s a -> (a -> MealyT f s b) -> MealyT f s b
when ma f = ifte ma f halt

instance functorMealy :: (Monad f) => Functor (MealyT f s) where
map f m = mealy $ \s -> g <$> stepMealy s m where
Expand Down Expand Up @@ -200,8 +201,6 @@ instance semigroupoidMealy :: (Monad f) => Semigroupoid (MealyT f) where
instance categoryMealy :: (Monad f) => Category (MealyT f) where
id = pureMealy $ \t -> Emit t halt

instance arrowMealy :: (Monad f) => Arrow (MealyT f)

instance bindMealy :: (Monad f) => Bind (MealyT f s) where
bind m f = mealy $ \s -> let g (Emit a m') = h <$> stepMealy s (f a)
where
Expand All @@ -222,10 +221,12 @@ instance plusMealy :: (Monad f) => Plus (MealyT f s) where

instance alternativeMealy :: (Monad f) => Alternative (MealyT f s)

instance monadZero :: (Monad f) => MonadZero (MealyT f s)

instance monadPlus :: (Monad f) => MonadPlus (MealyT f s)

instance monadEffMealy :: (Monad f, MonadEff eff f) => MonadEff eff (MealyT f s) where
liftEff = wrapEffect <<< liftEff

instance lazyMealy :: (Monad f) => Lazy (MealyT f s a) where
defer f = mealy \s -> runMealyT (f unit) >>= ($ s)
defer f = mealy \s -> runMealyT (f unit) >>= (_ $ s)

0 comments on commit a4b2206

Please sign in to comment.