@@ -16,20 +16,18 @@ data HTTP (m :: * -> *) k where
16 Post :: String -> HTTP m String
16 Post :: String -> HTTP m String
17 HGet :: HTTP m String
17 HGet :: HTTP m String
19−open' :: String -> HttpM ()
19+open' :: Has HTTP sig m => String -> m ()
20open' s = send (Open s)
20open' s = send (Open s)
22−close' :: HttpM ()
22+close' :: Has HTTP sig m => m ()
23close' = send Close
23close' = send Close
25−post' :: String -> HttpM String
25+post' :: Has HTTP sig m => String -> m String
26post' s = send (Post s)
26post' s = send (Post s)
28−get' :: HttpM String
28+get' :: Has HTTP sig m => m String
29get' = send HGet
29get' = send HGet
31−type HttpM = HttpC (LiftC IO)
33instance (Algebra sig m) => Algebra (HTTP :+: sig) (HttpC m) where
31instance (Algebra sig m) => Algebra (HTTP :+: sig) (HttpC m) where
34 alg hdl (L act) ctx = case act of
32 alg hdl (L act) ctx = case act of
35 Open _ -> pure ctx
33 Open _ -> pure ctx
@@ -38,10 +36,10 @@ instance (Algebra sig m) => Algebra (HTTP :+: sig) (HttpC m) where
38 HGet -> pure $ ctx $> "lmao"
36 HGet -> pure $ ctx $> "lmao"
39 alg hdl (R other) ctx = HttpC (alg (runHttpC . hdl) other ctx)
37 alg hdl (R other) ctx = HttpC (alg (runHttpC . hdl) other ctx)
41−runHttp :: HttpM a -> IO a
39+runHttp :: HttpC (LiftC IO) a -> IO a
42runHttp = runM . runHttpC
40runHttp = runM . runHttpC
44−doHTTP :: Int -> HttpC (LiftC IO) Int
42+doHTTP :: Has HTTP sig m => Int -> m Int
45doHTTP n = do
43doHTTP n = do
46 open' "cats"
44 open' "cats"
47 replicateM_ n (get' *> post' "cats")
45 replicateM_ n (get' *> post' "cats")