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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ addons:
- latexmk

node_js:
- '7'
- '11'

env:
matrix:
Expand All @@ -26,7 +26,7 @@ env:
- secure: "K3g58P0HUnRLIa2te30XL8xmyzuvimzG0z5R4C2+fku/gC6kkYs2MT/Cc3MFYHt9FPGGOTfys3UR0aPkq2bSL+Y5WXbjutY9PNqsvA2MqMLxdpZirTW6N6yP2l/ilMnPnJUNxScnErqvk4JKvdybYrAxYRA1mC2x3UknCL7uFLowFB/GU/XyTBY3mhu5uIB5I//Lr/oKMxT1M98hA4T5WHbLEE6K5ozypbsX5yU8OOgf6+ZZO9YegBS7vD9zlZNZivObfX+N0tmWkGLp+1WZiI5x0BaYuNU2oFq+hQie/tHAQTvcmKfprreRPGr1R95878G8OpVuoVLX3yXEfznfV62RYJodHsOUDFOMRXbgoBPRGK3GsCts8UaOg0efG4Y67pbMYgXHROtrLxlBfZasrcu6Odh+ZlmV4eraMi6muJWkRwga03i7BtwiP3Aw47+ycoMympupRyDlzk9HCO7ZyhYXsN25RCOsY6HQ6U6k9WvG421KPEPGz5g4hBuVqq5svA8wAdT3XUGIkYkfPmSi2SK2xEDJhz/g5E5HazM8lbmZfFYCB8fthz3XuRuiQqHQov3VrBPMWYa4VxMsvbc2NFc+4DwenE6PaOBwrwcH1zdtlWZB4YpyCZPeXFrQwm5uvm3I3YKijBb4sNjzLCeUSR7QkuMiYa/sE/tb1yYPhFc="

install:
- npm install -g bower pulp@12.3.0 "slamdata/node-purescript#0.12"
- npm install -g bower pulp@12.3.1 purescript@0.12.3
- bower install
- pip install --user -r docs/requirements.txt

Expand Down
14 changes: 14 additions & 0 deletions examples/QualifiedDo.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Examples.QualifiedDo where

import Prelude
import Effect (Effect)
import Hyper.Middleware as Middleware
import Hyper.Node.Server (defaultOptionsWithLogging, runServer)
import Hyper.Response (closeHeaders, respond, writeStatus)
import Hyper.Status (statusOK)

main :: Effect Unit
main = runServer defaultOptionsWithLogging {} Middleware.do
writeStatus statusOK
closeHeaders
respond "Hello, Hyper!"
10 changes: 9 additions & 1 deletion src/Hyper/Middleware.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
module Hyper.Middleware where
module Hyper.Middleware
( module QualifiedDo
, Middleware(..)
, evalMiddleware
, hoistMiddleware
, runMiddleware
, lift'
) where

import Prelude
import Control.Monad.Indexed (class IxApplicative, class IxApply, class IxBind, class IxFunctor, class IxMonad, ibind, ipure)
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (class MonadEffect, liftEffect)
import Data.Tuple (Tuple(..), snd)
import Hyper.Middleware.Class (class IxMonadMiddleware)
import Hyper.Middleware.QualifiedDo (bind, discard) as QualifiedDo

newtype Middleware m i o a = Middleware (i -> m (Tuple a o))

Expand Down
10 changes: 10 additions & 0 deletions src/Hyper/Middleware/QualifiedDo.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Hyper.Middleware.QualifiedDo where

import Control.Monad.Indexed (class IxBind, ibind)

bind :: forall a b x y z m. IxBind m => m x y a -> (a -> m y z b) -> m x z b
bind = ibind

discard :: forall a b x y z m. IxBind m => m x y a -> (a -> m y z b) -> m x z b
discard = ibind