Skip to content

Commit df350bb

Browse files
committed
Merge branch 'topic/q'
2 parents b0a2226 + 9fe1d0a commit df350bb

File tree

8 files changed

+307
-174
lines changed

8 files changed

+307
-174
lines changed

MODULE.md

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@
7575
removeAll :: forall e. Cache -> CacheEff e Unit
7676

7777

78+
## Module Angular.Deferred
79+
80+
### Types
81+
82+
data Deferred :: * -> * -> *
83+
84+
type DeferredEff e r = Eff (ngdeferred :: NgDeferred | e) r
85+
86+
data NgDeferred :: !
87+
88+
89+
### Values
90+
91+
notify :: forall e s a b. s -> Deferred a b -> DeferredEff e Unit
92+
93+
promise :: forall e a b. Deferred a b -> DeferredEff e (Promise a b)
94+
95+
reject :: forall e a b. a -> Deferred a b -> DeferredEff e Unit
96+
97+
resolve :: forall e a b. b -> Deferred a b -> DeferredEff e Unit
98+
99+
78100
## Module Angular.Element
79101

80102
### Types
@@ -231,44 +253,44 @@
231253

232254
### Types
233255

234-
type Config a b c = { responseType :: ResponseType, withCredentials :: Boolean, timeout :: Either Number (Promise c), cache :: Either Boolean Cache, xsrfCookieName :: String, xsrfHeaderName :: String, headers :: Headers, "data" :: RequestData b, params :: { | a }, url :: Url, method :: Method }
256+
type Config a b c d = { responseType :: ResponseType, withCredentials :: Boolean, timeout :: Either Number (Promise c d), cache :: Either Boolean Cache, xsrfCookieName :: String, xsrfHeaderName :: String, headers :: Headers, "data" :: RequestData b, params :: { | a }, url :: Url, method :: Method }
235257

236258
data Http :: *
237259

238-
type HttpResponse e r a b c = HttpEff e (Promise (Response r a b c))
260+
type HttpResponse e r a b c d = HttpEff e (Promise (Response r a b c d) (Response r a b c d))
239261

240-
type Response r a b c = { statusText :: String, config :: Config a b c, headers :: [String] -> String, status :: Status, "data" :: ResponseData r }
262+
type Response r a b c d = { statusText :: String, config :: Config a b c d, headers :: [String] -> String, status :: Status, "data" :: ResponseData r }
241263

242264

243265
### Values
244266

245-
config :: forall a b c. Config a b c
267+
config :: forall a b c d. Config a b c d
246268

247-
del :: forall e r a b c. Url -> Http -> HttpResponse e r a b c
269+
del :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
248270

249-
del' :: forall e r a b c. Url -> Config a b c -> Http -> HttpResponse e r a b c
271+
del' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
250272

251-
get :: forall e r a b c. Url -> Http -> HttpResponse e r a b c
273+
get :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
252274

253-
get' :: forall e r a b c. Url -> Config a b c -> Http -> HttpResponse e r a b c
275+
get' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
254276

255-
head :: forall e r a b c. Url -> Http -> HttpResponse e r a b c
277+
head :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
256278

257-
head' :: forall e r a b c. Url -> Config a b c -> Http -> HttpResponse e r a b c
279+
head' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
258280

259-
http :: forall e r a b c. Config a b c -> Http -> HttpResponse e r a b c
281+
http :: forall e r a b c d. Config a b c d -> Http -> HttpResponse e r a b c d
260282

261-
jsonp :: forall e r a b c. Url -> Http -> HttpResponse e r a b c
283+
jsonp :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
262284

263-
jsonp' :: forall e r a b c. Url -> Config a b c -> Http -> HttpResponse e r a b c
285+
jsonp' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
264286

265-
post :: forall e r a b c. Url -> RequestData b -> Http -> HttpResponse e r a b c
287+
post :: forall e r a b c d. Url -> RequestData b -> Http -> HttpResponse e r a b c d
266288

267-
post' :: forall e r a b c. Url -> RequestData b -> Config a b c -> Http -> HttpResponse e r a b c
289+
post' :: forall e r a b c d. Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
268290

269-
put :: forall e r a b c. Url -> RequestData b -> Http -> HttpResponse e r a b c
291+
put :: forall e r a b c d. Url -> RequestData b -> Http -> HttpResponse e r a b c d
270292

271-
put' :: forall e r a b c. Url -> RequestData b -> Config a b c -> Http -> HttpResponse e r a b c
293+
put' :: forall e r a b c d. Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
272294

273295

274296
## Module Angular.Injector
@@ -425,47 +447,61 @@
425447
viewValue :: forall e a. NgModelController a -> NgModelEff e String
426448

427449

428-
## Module Angular.Q
450+
## Module Angular.Promise
429451

430452
### Types
431453

432-
data Promise :: * -> *
433-
434-
data Q :: *
454+
data Promise :: * -> * -> *
435455

436456

437457
### Type Class Instances
438458

439-
instance applicativePromise :: Applicative Promise
459+
instance applicativePromise :: Applicative (Promise a)
440460

441-
instance applyPromise :: Apply Promise
461+
instance applyPromise :: Apply (Promise a)
442462

443-
instance bindPromise :: Bind Promise
463+
instance bifunctorPromise :: Bifunctor Promise
444464

445-
instance functorPromise :: Functor Promise
465+
instance bindPromise :: Bind (Promise a)
446466

447-
instance monadPromise :: Monad Promise
467+
instance functorPromise :: Functor (Promise a)
468+
469+
instance monadPromise :: Monad (Promise a)
448470

449471

450472
### Values
451473

452-
all :: forall a. [Promise a] -> Q -> Promise [a]
474+
catch' :: forall a b c d. (a -> Promise c d) -> Promise a b -> Promise c d
475+
476+
finally' :: forall e r a b. Eff e r -> Promise a b -> Promise a b
453477

454-
catch' :: forall a b c. Promise a -> (b -> Promise c) -> Promise c
478+
then' :: forall a b c d. (b -> Promise c d) -> Promise a b -> Promise c d
455479

456-
finally' :: forall a b. Promise a -> (Unit -> b) -> Promise a
480+
then'' :: forall a b c d. (b -> Promise c d) -> (a -> Promise c d) -> Promise a b -> Promise c d
457481

458-
reject :: forall a. a -> Q -> Promise a
482+
then''' :: forall e s t a b c d. (b -> Promise c d) -> (a -> Promise c d) -> (s -> Eff e t) -> Promise a b -> Promise c d
459483

460-
resolve :: forall a. a -> Q -> Promise a
461484

462-
then' :: forall a b. Promise a -> (a -> Promise b) -> Promise b
485+
## Module Angular.Q
486+
487+
### Types
488+
489+
data NgQ :: !
490+
491+
data Q :: *
492+
493+
type QEff e r = Eff (ngq :: NgQ | e) r
494+
495+
496+
### Values
497+
498+
all :: forall e a b. [Promise a b] -> Q -> QEff e (Promise b [a])
463499

464-
then'' :: forall a b c. Promise a -> (a -> Promise b) -> (c -> Promise b) -> Promise b
500+
defer :: forall e a b. Q -> QEff e (Deferred a b)
465501

466-
then''' :: forall a b c d. Promise a -> (a -> Promise b) -> (b -> Promise b) -> (c -> d) -> Promise b
502+
reject :: forall e a b. a -> Q -> QEff e (Promise a b)
467503

468-
when :: forall a. a -> Q -> Promise a
504+
when :: forall e a b. b -> Q -> QEff e (Promise a b)
469505

470506

471507
## Module Angular.ST
@@ -657,7 +693,7 @@
657693

658694
getConfigResponseType :: ForeignConfig -> ResponseType
659695

660-
getConfigTimeout :: forall r. ForeignConfig -> Either Number (Promise r)
696+
getConfigTimeout :: forall a b. ForeignConfig -> Either Number (Promise a b)
661697

662698
getConfigUrl :: ForeignConfig -> Url
663699

@@ -689,7 +725,7 @@
689725

690726
setConfigResponseType :: forall e. ResponseType -> ForeignConfig -> HttpEff e Unit
691727

692-
setConfigTimeout :: forall e a. Either Number (Promise a) -> ForeignConfig -> HttpEff e Unit
728+
setConfigTimeout :: forall e a b. Either Number (Promise a b) -> ForeignConfig -> HttpEff e Unit
693729

694730
setConfigUrl :: forall e. Url -> ForeignConfig -> HttpEff e Unit
695731

@@ -806,7 +842,7 @@
806842

807843
readStatus :: Number -> Status
808844

809-
readTimeoutFn :: forall r. Fn3 (Number -> Either Number (Promise r)) (Promise r -> Either Number (Promise r)) ForeignTimeout (Either Number (Promise r))
845+
readTimeoutFn :: forall a b. Fn3 (Number -> Either Number (Promise a b)) (Promise a b -> Either Number (Promise a b)) ForeignTimeout (Either Number (Promise a b))
810846

811847
stringHeader :: String -> String -> Header
812848

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dist"
1818
],
1919
"dependencies": {
20+
"purescript-bifunctors": "0.0.4",
2021
"purescript-either": "0.1.2",
2122
"purescript-foldable-traversable": "0.1.3",
2223
"purescript-maybe": "0.2.0",

src/Angular/Deferred.purs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module Angular.Deferred
2+
( Deferred()
3+
, NgDeferred()
4+
, DeferredEff()
5+
, resolve
6+
, reject
7+
, notify
8+
, promise
9+
) where
10+
11+
import Control.Monad.Eff
12+
import Data.Function
13+
14+
import Angular.Promise (Promise())
15+
16+
foreign import data Deferred :: * -> * -> *
17+
18+
foreign import data NgDeferred :: !
19+
20+
type DeferredEff e r = Eff (ngdeferred :: NgDeferred | e) r
21+
22+
foreign import resolveFn
23+
" function resolveFn(a, dfd){ \
24+
\ return function(){ \
25+
\ dfd.resolve(a); \
26+
\ }; \
27+
\ } "
28+
:: forall e a b. Fn2 b (Deferred a b) (DeferredEff e Unit)
29+
30+
resolve :: forall e a b. b -> Deferred a b -> DeferredEff e Unit
31+
resolve = runFn2 resolveFn
32+
33+
foreign import rejectFn
34+
" function rejectFn(a, dfd){ \
35+
\ return function(){ \
36+
\ dfd.reject(a); \
37+
\ }; \
38+
\ } "
39+
:: forall e a b. Fn2 a (Deferred a b) (DeferredEff e Unit)
40+
41+
reject :: forall e a b. a -> Deferred a b -> DeferredEff e Unit
42+
reject = runFn2 rejectFn
43+
44+
foreign import notifyFn
45+
" function notifyFn(a, dfd){ \
46+
\ return function(){ \
47+
\ dfd.notify(a); \
48+
\ }; \
49+
\ } "
50+
:: forall e s a b. Fn2 s (Deferred a b) (DeferredEff e Unit)
51+
52+
notify :: forall e s a b. s -> Deferred a b -> DeferredEff e Unit
53+
notify = runFn2 notifyFn
54+
55+
foreign import promise
56+
" function promise(dfd){ \
57+
\ return function(){ \
58+
\ dfd.promise; \
59+
\ }; \
60+
\ } "
61+
:: forall e a b. Deferred a b -> DeferredEff e (Promise a b)

0 commit comments

Comments
 (0)