From f34d2ce398d6dce01f48dfe084ffba1c6277c5e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Mon, 18 Nov 2019 00:04:13 +0100
Subject: [PATCH] Remove wrapActions and wrapRoutes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There were kind of weird anyway.
I do not want to confuse users.

Signed-off-by: Jan Hamal Dvořák <mordae@anilinux.org>
---
 lib/Hikaru/Dispatch.hs | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/lib/Hikaru/Dispatch.hs b/lib/Hikaru/Dispatch.hs
index f749b55..75dcb43 100644
--- a/lib/Hikaru/Dispatch.hs
+++ b/lib/Hikaru/Dispatch.hs
@@ -16,9 +16,7 @@ module Hikaru.Dispatch
   -- ** Routes
   , route
   , wrapRoute
-  , wrapRoutes
   , wrapAction
-  , wrapActions
 
   -- ** Middleware
   , middleware
@@ -172,42 +170,25 @@ where
        in env { envRoutes = envRoutes env' <> envRoutes env }
 
 
-  -- |
-  -- Wrap all /following/ routes with a route transformer.
-  --
-  wrapRoutes :: (Route r -> Route r) -> Dispatch r l ()
-  wrapRoutes wrapper = Dispatch do
-    modify \env -> env { envRouteW = envRouteW env . wrapper }
-
-
   -- |
   -- Wrap all nested actions with an action transformer.
   --
-  wrapAction :: (r -> r) -> Dispatch r Nested a -> Dispatch r l ()
-  wrapAction wrapper disp = Dispatch do
-    modify \env ->
-      let env' = execState (unDispatch disp)
-                           (env { envActionW = envActionW env . wrapper })
-       in env { envRoutes = envRoutes env' <> envRoutes env }
-
-
-  -- |
-  -- Wrap all /following/ actions with an action transformer.
-  --
   -- This can come in handy e.g. to tune cache control:
   --
   -- @
   -- app :: Application
   -- app = 'dispatch' runAction $ do
-  --   'wrapRoutes' ('Hikaru.Action.defaultHeader' hCacheControl "no-cache" >>)
-  --
-  --   'route' $ getRootR  \<$ 'get'
-  --   'route' $ getHelloR \<$ 'get' <* 'seg' "hello" \<*\> 'arg'
+  --   'wrapAction' ('Hikaru.Action.defaultHeader' hCacheControl "no-cache" >>) $ do
+  --     'route' $ getRootR  \<$ 'get'
+  --     'route' $ getHelloR \<$ 'get' <* 'seg' "hello" \<*\> 'arg'
   -- @
   --
-  wrapActions :: (r -> r) -> Dispatch r l ()
-  wrapActions wrapper = Dispatch do
-    modify \env -> env { envActionW = envActionW env . wrapper }
+  wrapAction :: (r -> r) -> Dispatch r Nested a -> Dispatch r l ()
+  wrapAction wrapper disp = Dispatch do
+    modify \env ->
+      let env' = execState (unDispatch disp)
+                           (env { envActionW = envActionW env . wrapper })
+       in env { envRoutes = envRoutes env' <> envRoutes env }
 
 
   -- |
-- 
GitLab