diff --git a/.travis.yml b/.travis.yml index 0a0c3ee..2d3abe9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: - latexmk node_js: -- '7' +- '11' env: matrix: @@ -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 diff --git a/examples/QualifiedDo.purs b/examples/QualifiedDo.purs new file mode 100644 index 0000000..adf6a75 --- /dev/null +++ b/examples/QualifiedDo.purs @@ -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!" diff --git a/src/Hyper/Middleware.purs b/src/Hyper/Middleware.purs index d5f392d..3240263 100644 --- a/src/Hyper/Middleware.purs +++ b/src/Hyper/Middleware.purs @@ -1,4 +1,11 @@ -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) @@ -6,6 +13,7 @@ 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)) diff --git a/src/Hyper/Middleware/QualifiedDo.purs b/src/Hyper/Middleware/QualifiedDo.purs new file mode 100644 index 0000000..a959599 --- /dev/null +++ b/src/Hyper/Middleware/QualifiedDo.purs @@ -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 +