@@ -3,6 +3,7 @@ module Network.HTTP.Affjax
33 , Affjax ()
44 , AffjaxOptions ()
55 , AffjaxResponse ()
6+ , URL ()
67 , url , method , content , headers , username , password
78 , affjax
89 , affjax'
@@ -43,8 +44,11 @@ type AffjaxResponse a =
4344 , response :: a
4445 }
4546
47+ -- | Type alias for URL strings to aid readability of types.
48+ type URL = String
49+
4650-- | Sets the URL for a request.
47- url :: Option AffjaxOptions String
51+ url :: Option AffjaxOptions URL
4852url = opt " url"
4953
5054-- | Sets the HTTP method for a request.
@@ -92,32 +96,32 @@ affjax' (Responsable read ty) opts eb cb =
9296 Left err -> eb $ error (show err )
9397 Right res' -> cb res'
9498
95- get :: forall e a . Responsable a -> String -> Affjax e a
96- get r addr = affjax r $ method := GET
97- <> url := addr
99+ get :: forall e a . URL -> Responsable a -> Affjax e a
100+ get u r = affjax r $ method := GET
101+ <> url := u
98102
99- post :: forall e a . Responsable a -> String -> RequestContent -> Affjax e a
100- post r u c = affjax r $ method := POST
103+ post :: forall e a . URL -> Responsable a -> RequestContent -> Affjax e a
104+ post u r c = affjax r $ method := POST
101105 <> url := u
102106 <> content := c
103107
104- post_ :: forall e . String -> RequestContent -> Affjax e Unit
105- post_ = post rUnit
108+ post_ :: forall e . URL -> RequestContent -> Affjax e Unit
109+ post_ = flip post rUnit
106110
107- put :: forall e a . Responsable a -> String -> RequestContent -> Affjax e a
108- put r u c = affjax r $ method := PUT
111+ put :: forall e a . URL -> Responsable a -> RequestContent -> Affjax e a
112+ put u r c = affjax r $ method := PUT
109113 <> url := u
110114 <> content := c
111115
112- put_ :: forall e . String -> RequestContent -> Affjax e Unit
113- put_ = put rUnit
116+ put_ :: forall e . URL -> RequestContent -> Affjax e Unit
117+ put_ = flip put rUnit
114118
115- delete :: forall e a . Responsable a -> String -> Affjax e a
116- delete r u = affjax r $ method := DELETE
119+ delete :: forall e a . URL -> Responsable a -> Affjax e a
120+ delete u r = affjax r $ method := DELETE
117121 <> url := u
118122
119- delete_ :: forall e . String -> Affjax e Unit
120- delete_ = delete rUnit
123+ delete_ :: forall e . URL -> Affjax e Unit
124+ delete_ = flip delete rUnit
121125
122126foreign import unsafeAjax
123127 " " "
0 commit comments