Skip to content

Add newtype instance for Match, tweak readme/build #28

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
Nov 3, 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: stable
install:
- npm install -g bower
- npm install
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# purescript-routing

[![Latest release](http://img.shields.io/bower/v/purescript-routing.svg)](https://github.com/slamdata/purescript-routing/releases)
[![Build Status](https://travis-ci.org/slamdata/purescript-routing.svg?branch=master)](https://travis-ci.org/slamdata/purescript-routing)
[![Dependency Status](https://www.versioneye.com/user/projects/56e4cf18df573d00495abcf7/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56e4cf18df573d00495abcf7)
[![Latest release](http://img.shields.io/github/release/slamdata/purescript-routing.svg)](https://github.com/slamdata/purescript-routing/releases)
[![Build status](https://travis-ci.org/slamdata/purescript-routing.svg?branch=master)](https://travis-ci.org/slamdata/purescript-routing)

Client side routing library.

Expand Down
31 changes: 17 additions & 14 deletions src/Routing/Match.purs
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
module Routing.Match where

import Prelude

import Prelude (class Applicative, class Apply, class Functor, pure, bind, const, one, id, unit, ($), (<<<), (<$>), (<>), (*), (==))
import Data.Either (Either(..))
import Data.Tuple (Tuple(..), snd)
import Data.Maybe (Maybe(..))
import Data.List (List(..), reverse)
import Control.Alt (class Alt, (<|>))
import Control.Plus (class Plus)
import Control.Alternative (class Alternative)
import Global (readFloat, isNaN)
import Data.Semiring.Free (Free(), free)
import Control.Plus (class Plus)

import Data.Either (Either(..))
import Data.Foldable (foldl)
import Data.List (List(..), reverse)
import Data.Map as M
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype, unwrap)
import Data.Semiring.Free (Free(), free)
import Data.Tuple (Tuple(..), snd)
import Data.Validation.Semiring (V, invalid, unV)
import Data.Newtype (unwrap)


import Data.Map as M
import Global (readFloat, isNaN)

import Routing.Types (Route, RoutePart(..))
import Routing.Match.Class (class MatchClass)
import Routing.Match.Error (MatchError(..), showMatchError)
import Routing.Types (Route, RoutePart(..))

newtype Match a = Match (Route -> V (Free MatchError) (Tuple Route a))
unMatch :: forall a. Match a -> (Route -> V (Free MatchError) (Tuple Route a))
unMatch (Match a) = a

-- Manual instance due to the `Route` synonym in the above
instance newtypeMatch :: Newtype (Match a) (List RoutePart -> V (Free MatchError) (Tuple (List RoutePart) a)) where
wrap = Match
unwrap (Match m) = m

instance matchMatchClass :: MatchClass Match where
lit input = Match \route ->
Expand Down