Skip to content

Commit fced384

Browse files
committed
Merge pull request #15 from slamdata/updates
Update Aff, uppercase effect
2 parents 5078138 + a8d955a commit fced384

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
## Module Network.HTTP.Affjax
44

5-
#### `Ajax`
5+
#### `AJAX`
66

77
``` purescript
8-
data Ajax :: !
8+
data AJAX :: !
99
```
1010

1111
The effect type for AJAX requests made with Affjax.
1212

1313
#### `Affjax`
1414

1515
``` purescript
16-
type Affjax e a = Aff (ajax :: Ajax | e) (AffjaxResponse a)
16+
type Affjax e a = Aff (ajax :: AJAX | e) (AffjaxResponse a)
1717
```
1818

1919
The type for Affjax requests.
@@ -151,7 +151,7 @@ Makes a `DELETE` request to the specified URL and ignores the response.
151151
#### `affjax'`
152152

153153
``` purescript
154-
affjax' :: forall e a b. (Requestable a, Responsable b) => AffjaxRequest a -> (Error -> Eff (ajax :: Ajax | e) Unit) -> (AffjaxResponse b -> Eff (ajax :: Ajax | e) Unit) -> Eff (ajax :: Ajax | e) (Canceler (ajax :: Ajax | e))
154+
affjax' :: forall e a b. (Requestable a, Responsable b) => AffjaxRequest a -> (Error -> Eff (ajax :: AJAX | e) Unit) -> (AffjaxResponse b -> Eff (ajax :: AJAX | e) Unit) -> Eff (ajax :: AJAX | e) (Canceler (ajax :: AJAX | e))
155155
```
156156

157157
Run a request directly without using `Aff`.

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"package.json"
2020
],
2121
"dependencies": {
22-
"purescript-aff": "~0.9.2",
22+
"purescript-aff": "~0.10.0",
2323
"purescript-arraybuffer-types": "~0.1.1",
2424
"purescript-dom": "~0.1.2",
2525
"purescript-foreign": "~0.4.2",

src/Network/HTTP/Affjax.purs

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Network.HTTP.Affjax
2-
( Ajax()
2+
( AJAX()
33
, Affjax()
44
, AffjaxRequest(), defaultRequest
55
, AffjaxResponse()
@@ -12,7 +12,7 @@ module Network.HTTP.Affjax
1212
, delete, delete_
1313
) where
1414

15-
import Control.Monad.Aff (Aff(), makeAff, makeAff', Canceler())
15+
import Control.Monad.Aff (Aff(), makeAff, makeAff', Canceler(..))
1616
import Control.Monad.Eff (Eff())
1717
import Control.Monad.Eff.Exception (Error(), error)
1818
import Data.Either (Either(..))
@@ -31,10 +31,10 @@ import Network.HTTP.StatusCode (StatusCode())
3131
import Type.Proxy (Proxy(..))
3232

3333
-- | The effect type for AJAX requests made with Affjax.
34-
foreign import data Ajax :: !
34+
foreign import data AJAX :: !
3535

3636
-- | The type for Affjax requests.
37-
type Affjax e a = Aff (ajax :: Ajax | e) (AffjaxResponse a)
37+
type Affjax e a = Aff (ajax :: AJAX | e) (AffjaxResponse a)
3838

3939
type AffjaxRequest a =
4040
{ method :: Method
@@ -120,9 +120,9 @@ delete_ = delete
120120
-- | Run a request directly without using `Aff`.
121121
affjax' :: forall e a b. (Requestable a, Responsable b) =>
122122
AffjaxRequest a ->
123-
(Error -> Eff (ajax :: Ajax | e) Unit) ->
124-
(AffjaxResponse b -> Eff (ajax :: Ajax | e) Unit) ->
125-
Eff (ajax :: Ajax | e) (Canceler (ajax :: Ajax | e))
123+
(Error -> Eff (ajax :: AJAX | e) Unit) ->
124+
(AffjaxResponse b -> Eff (ajax :: AJAX | e) Unit) ->
125+
Eff (ajax :: AJAX | e) (Canceler (ajax :: AJAX | e))
126126
affjax' req eb cb =
127127
runFn5 _ajax responseHeader req' cancelAjax eb cb'
128128
where
@@ -135,7 +135,7 @@ affjax' req eb cb =
135135
, username: toNullable req.username
136136
, password: toNullable req.password
137137
}
138-
cb' :: AffjaxResponse ResponseContent -> Eff (ajax :: Ajax | e) Unit
138+
cb' :: AffjaxResponse ResponseContent -> Eff (ajax :: AJAX | e) Unit
139139
cb' res = case res { response = _ } <$> fromResponse res.response of
140140
Left err -> eb $ error (show err)
141141
Right res' -> cb res'
@@ -185,13 +185,13 @@ foreign import _ajax
185185
}
186186
""" :: forall e a. Fn5 (String -> String -> ResponseHeader)
187187
AjaxRequest
188-
(XMLHttpRequest -> Canceler (ajax :: Ajax | e))
189-
(Error -> Eff (ajax :: Ajax | e) Unit)
190-
(AffjaxResponse Foreign -> Eff (ajax :: Ajax | e) Unit)
191-
(Eff (ajax :: Ajax | e) (Canceler (ajax :: Ajax | e)))
188+
(XMLHttpRequest -> Canceler (ajax :: AJAX | e))
189+
(Error -> Eff (ajax :: AJAX | e) Unit)
190+
(AffjaxResponse Foreign -> Eff (ajax :: AJAX | e) Unit)
191+
(Eff (ajax :: AJAX | e) (Canceler (ajax :: AJAX | e)))
192192

193-
cancelAjax :: forall e. XMLHttpRequest -> Canceler (ajax :: Ajax | e)
194-
cancelAjax xhr err = makeAff (\eb cb -> runFn4 _cancelAjax xhr err eb cb)
193+
cancelAjax :: forall e. XMLHttpRequest -> Canceler (ajax :: AJAX | e)
194+
cancelAjax xhr = Canceler \err -> makeAff (\eb cb -> runFn4 _cancelAjax xhr err eb cb)
195195

196196
foreign import _cancelAjax
197197
"""
@@ -203,6 +203,6 @@ foreign import _cancelAjax
203203
};
204204
""" :: forall e. Fn4 XMLHttpRequest
205205
Error
206-
(Error -> Eff (ajax :: Ajax | e) Unit)
207-
(Boolean -> Eff (ajax :: Ajax | e) Unit)
208-
(Eff (ajax :: Ajax | e) Unit)
206+
(Error -> Eff (ajax :: AJAX | e) Unit)
207+
(Boolean -> Eff (ajax :: AJAX | e) Unit)
208+
(Eff (ajax :: AJAX | e) Unit)

test/Main.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ main = launchAff $ do
3939
liftEff $ either traceAny (traceAny :: AffjaxResponse Foreign -> _) res
4040

4141
canceler <- forkAff (post_ "/api" "do it now")
42-
canceled <- canceler $ error "Pull the cord!"
42+
canceled <- canceler `cancel` error "Pull the cord!"
4343
liftEff $ if canceled then (trace "Canceled") else (trace "Not Canceled")

0 commit comments

Comments
 (0)