Skip to content

Commit d19cdde

Browse files
committed
Merge pull request #16 from dylex/simpledom
Use purescript-simple-dom for #4
2 parents bb0cb5e + 771ce47 commit d19cdde

File tree

11 files changed

+127
-307
lines changed

11 files changed

+127
-307
lines changed

MODULE.md

Lines changed: 26 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@
231231

232232
data Element :: *
233233

234-
type Handler e = Event -> Eff e Unit
234+
type Handler e = DOMEvent -> Eff e Unit
235235

236236
data NgEl :: !
237237

238238

239239
### Values
240240

241-
(!!) :: Element -> Number -> Maybe Node
241+
(!!) :: Element -> Number -> Maybe HTMLElement
242242

243243
addClass :: forall e. String -> Element -> ElEff e Element
244244

@@ -377,44 +377,44 @@
377377

378378
### Types
379379

380-
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 }
380+
type Config a b c d = { responseType :: D.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 :: D.Url, method :: D.HttpMethod }
381381

382382
data Http :: *
383383

384384
type HttpResponse e r a b c d = HttpEff e (Promise (Response r a b c d) (Response r a b c d))
385385

386-
type Response r a b c d = { statusText :: String, config :: Config a b c d, headers :: [String] -> String, status :: Status, "data" :: ResponseData r }
386+
type Response r a b c d = { statusText :: String, config :: Config a b c d, headers :: [String] -> String, status :: Status, "data" :: D.HttpData r }
387387

388388

389389
### Values
390390

391391
config :: forall a b c d. Config a b c d
392392

393-
del :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
393+
del :: forall e r a b c d. D.Url -> Http -> HttpResponse e r a b c d
394394

395-
del' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
395+
del' :: forall e r a b c d. D.Url -> Config a b c d -> Http -> HttpResponse e r a b c d
396396

397-
get :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
397+
get :: forall e r a b c d. D.Url -> Http -> HttpResponse e r a b c d
398398

399-
get' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
399+
get' :: forall e r a b c d. D.Url -> Config a b c d -> Http -> HttpResponse e r a b c d
400400

401-
head :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
401+
head :: forall e r a b c d. D.Url -> Http -> HttpResponse e r a b c d
402402

403-
head' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
403+
head' :: forall e r a b c d. D.Url -> Config a b c d -> Http -> HttpResponse e r a b c d
404404

405405
http :: forall e r a b c d. Config a b c d -> Http -> HttpResponse e r a b c d
406406

407-
jsonp :: forall e r a b c d. Url -> Http -> HttpResponse e r a b c d
407+
jsonp :: forall e r a b c d. D.Url -> Http -> HttpResponse e r a b c d
408408

409-
jsonp' :: forall e r a b c d. Url -> Config a b c d -> Http -> HttpResponse e r a b c d
409+
jsonp' :: forall e r a b c d. D.Url -> Config a b c d -> Http -> HttpResponse e r a b c d
410410

411-
post :: forall e r a b c d. Url -> RequestData b -> Http -> HttpResponse e r a b c d
411+
post :: forall e r a b c d. D.Url -> RequestData b -> Http -> HttpResponse e r a b c d
412412

413-
post' :: forall e r a b c d. Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
413+
post' :: forall e r a b c d. D.Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
414414

415-
put :: forall e r a b c d. Url -> RequestData b -> Http -> HttpResponse e r a b c d
415+
put :: forall e r a b c d. D.Url -> RequestData b -> Http -> HttpResponse e r a b c d
416416

417-
put' :: forall e r a b c d. Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
417+
put' :: forall e r a b c d. D.Url -> RequestData b -> Config a b c d -> Http -> HttpResponse e r a b c d
418418

419419

420420
## Module Angular.Injector
@@ -888,44 +888,6 @@
888888
timeoutk :: forall e f r. Number -> Boolean -> Timeout -> Eff f r -> TimeoutEff e (TimeoutPromise r)
889889

890890

891-
## Module DOM.Event
892-
893-
### Types
894-
895-
type Event = { keyCode :: Number }
896-
897-
898-
## Module DOM.Node
899-
900-
### Types
901-
902-
data DOM :: !
903-
904-
data Node :: *
905-
906-
907-
### Values
908-
909-
focus :: forall e. Node -> Eff (dom :: DOM | e) Unit
910-
911-
912-
## Module DOM.Types
913-
914-
### Types
915-
916-
data ArrayBuffer :: *
917-
918-
data Blob :: *
919-
920-
data Document :: *
921-
922-
data MozBlob :: *
923-
924-
data MozChunkedArrayBuffer :: *
925-
926-
data MozChunkedText :: *
927-
928-
929891
## Module Angular.Http.Internal
930892

931893
### Types
@@ -943,17 +905,17 @@
943905

944906
getConfigHeaders :: ForeignConfig -> Headers
945907

946-
getConfigMethod :: ForeignConfig -> Method
908+
getConfigMethod :: ForeignConfig -> D.HttpMethod
947909

948910
getConfigParams :: forall a. ForeignConfig -> { | a }
949911

950912
getConfigRequestData :: forall e a. ForeignConfig -> RequestData a
951913

952-
getConfigResponseType :: ForeignConfig -> ResponseType
914+
getConfigResponseType :: ForeignConfig -> D.ResponseType
953915

954916
getConfigTimeout :: forall a b. ForeignConfig -> Either Number (Promise a b)
955917

956-
getConfigUrl :: ForeignConfig -> Url
918+
getConfigUrl :: ForeignConfig -> D.Url
957919

958920
getConfigWithCredentials :: ForeignConfig -> Boolean
959921

@@ -963,7 +925,7 @@
963925

964926
getResponseConfig :: ForeignResponse -> ForeignConfig
965927

966-
getResponseData :: forall a. ResponseType -> ForeignResponse -> ResponseData a
928+
getResponseData :: forall a. D.ResponseType -> ForeignResponse -> D.HttpData a
967929

968930
getResponseHeaders :: ForeignResponse -> [String] -> String
969931

@@ -975,17 +937,17 @@
975937

976938
setConfigHeaders :: forall e. Headers -> ForeignConfig -> HttpEff e Unit
977939

978-
setConfigMethod :: forall e. Method -> ForeignConfig -> HttpEff e Unit
940+
setConfigMethod :: forall e. D.HttpMethod -> ForeignConfig -> HttpEff e Unit
979941

980942
setConfigParams :: forall e a. { | a } -> ForeignConfig -> HttpEff e Unit
981943

982944
setConfigRequestData :: forall e a. RequestData a -> ForeignConfig -> HttpEff e Unit
983945

984-
setConfigResponseType :: forall e. ResponseType -> ForeignConfig -> HttpEff e Unit
946+
setConfigResponseType :: forall e. D.ResponseType -> ForeignConfig -> HttpEff e Unit
985947

986948
setConfigTimeout :: forall e a b. Either Number (Promise a b) -> ForeignConfig -> HttpEff e Unit
987949

988-
setConfigUrl :: forall e. Url -> ForeignConfig -> HttpEff e Unit
950+
setConfigUrl :: forall e. D.Url -> ForeignConfig -> HttpEff e Unit
989951

990952
setConfigWithCredentials :: forall e. Boolean -> ForeignConfig -> HttpEff e Unit
991953

@@ -1015,16 +977,6 @@
1015977

1016978
type HttpEff e r = Eff (nghttp :: NgHttp | e) r
1017979

1018-
data Method where
1019-
GET :: Method
1020-
POST :: Method
1021-
PUT :: Method
1022-
DELETE :: Method
1023-
PATCH :: Method
1024-
HEAD :: Method
1025-
OPTIONS :: Method
1026-
JSONP :: Method
1027-
1028980
data NgHttp :: !
1029981

1030982
data RequestData a where
@@ -1034,31 +986,6 @@
1034986

1035987
type RequestDataFn a = { objectRequestData :: a -> RequestData a, stringRequestData :: String -> RequestData a, noRequestData :: RequestData a }
1036988

1037-
data ResponseData a where
1038-
NoResponseData :: ResponseData a
1039-
DefaultResponseData :: String -> ResponseData a
1040-
ArrayBufferResponseData :: D.ArrayBuffer -> ResponseData a
1041-
BlobResponseData :: D.Blob -> ResponseData a
1042-
DocumentResponseData :: D.Document -> ResponseData a
1043-
JsonResponseData :: a -> ResponseData a
1044-
TextResponseData :: String -> ResponseData a
1045-
MozBlobResponseData :: D.MozBlob -> ResponseData a
1046-
MozChunkedTextResponseData :: D.MozChunkedText -> ResponseData a
1047-
MozChunkedArrayBufferResponseData :: D.MozChunkedArrayBuffer -> ResponseData a
1048-
1049-
type ResponseDataFn a = { mozChunkedArrayBufferResponseData :: D.MozChunkedArrayBuffer -> ResponseData a, mozChunkedTextResponseData :: D.MozChunkedText -> ResponseData a, mozBlobResponseData :: D.MozBlob -> ResponseData a, textResponseData :: String -> ResponseData a, jsonResponseData :: a -> ResponseData a, documentResponseData :: D.Document -> ResponseData a, blobResponseData :: D.Blob -> ResponseData a, arrayBufferResponseData :: D.ArrayBuffer -> ResponseData a, defaultResponseData :: String -> ResponseData a, noResponseData :: ResponseData a }
1050-
1051-
data ResponseType where
1052-
Default :: ResponseType
1053-
ArrayBuffer :: ResponseType
1054-
Blob :: ResponseType
1055-
Document :: ResponseType
1056-
Json :: ResponseType
1057-
Text :: ResponseType
1058-
MozBlob :: ResponseType
1059-
MozChunkedText :: ResponseType
1060-
MozChunkedArrayBuffer :: ResponseType
1061-
1062989
data Status where
1063990
OK :: Status
1064991
Created :: Status
@@ -1070,15 +997,6 @@
1070997
InternalServerError :: Status
1071998
OtherStatus :: Number -> Status
1072999

1073-
type Url = String
1074-
1075-
1076-
### Type Class Instances
1077-
1078-
instance showMethod :: Show Method
1079-
1080-
instance showResponseType :: Show ResponseType
1081-
10821000

10831001
### Values
10841002

@@ -1090,13 +1008,13 @@
10901008

10911009
readHeadersFn :: forall a b. Fn4 (String -> Either String (Unit -> String)) ((Unit -> String) -> Either String (Unit -> String)) (String -> Either String (Unit -> String) -> Header) ForeignHeaders Headers
10921010

1093-
readMethod :: String -> Method
1011+
readMethod :: String -> D.HttpMethod
10941012

10951013
readRequestDataFn :: forall a. Fn2 (RequestDataFn a) ForeignRequestData (RequestData a)
10961014

1097-
readResponseDataFn :: forall a. Fn3 (ResponseDataFn a) String ForeignResponseData (ResponseData a)
1015+
readResponseData :: forall a d. (d -> D.HttpData a) -> ForeignResponseData -> D.HttpData a
10981016

1099-
readResponseType :: String -> ResponseType
1017+
readResponseType :: String -> D.ResponseType
11001018

11011019
readStatus :: Number -> Status
11021020

bower.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
"dist"
1818
],
1919
"dependencies": {
20-
"purescript-bifunctors": "0.0.4",
20+
"purescript-bifunctors": "0.0.6",
2121
"purescript-either": "0.1.3",
2222
"purescript-exceptions": "0.2.1",
23-
"purescript-foldable-traversable": "0.1.3",
23+
"purescript-foldable-traversable": "0.1.4",
2424
"purescript-maybe": "0.2.1",
25-
"purescript-tuples": "0.2.1"
25+
"purescript-tuples": "0.2.1",
26+
"purescript-simple-dom": "git://github.com/aktowns/purescript-simple-dom.git"
2627
},
2728
"devDependencies": {
2829
"angular": "1.2.26",
2930
"todomvc-common": "0.1.9",
30-
"purescript-strings": "0.2.1",
31-
"purescript-arrays": "0.2.0",
31+
"purescript-strings": "0.3.3",
32+
"purescript-arrays": "0.2.1",
3233
"purescript-control": "0.2.1"
3334
}
3435
}

examples/Todomvc/Escape.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module Todomvc.Escape (EscapeDirective(), escape) where
22

33
import Data.Maybe
4+
import Control.Bind ((>=>))
5+
6+
import Data.DOM.Simple.Events (keyCode)
47

58
import Angular.Attributes (get)
69
import Angular.Element (on)
@@ -11,7 +14,8 @@ foreign import data EscapeDirective :: *
1114
escapeKey = 27
1215

1316
link scope element attrs = do
14-
on "keydown" (\e -> if e.keyCode == escapeKey
17+
on "keydown" (keyCode >=> \kc ->
18+
if kc == escapeKey
1519
then (get attrs) >>= (\as -> apply (stringApplyExpr as.todoEscape) scope)
1620
else return unit) element
1721

examples/Todomvc/Focus.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Data.Maybe
44
import Control.Monad (when)
55
import Control.Monad.Eff
66

7-
import qualified DOM.Node as D
7+
import qualified Data.DOM.Simple.Element as D
88

99
import Angular.Attributes (get)
1010
import Angular.Element ((!!))

src/Angular/Element.purs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@ import Control.Monad.Eff
6262
import Data.Function (Fn3(), Fn4(), Fn5(), runFn3, runFn4, runFn5)
6363
import Data.Maybe
6464

65-
import DOM.Event (Event())
66-
import DOM.Node (Node())
65+
import Data.DOM.Simple.Types (HTMLElement(), DOMEvent())
6766

6867
import Angular.Injector (Injector())
6968
import Angular.Scope (Scope())
7069

7170
type ElEff e r = Eff (ngel :: NgEl | e) r
7271

73-
type Handler e = Event -> Eff e Unit
72+
type Handler e = DOMEvent -> Eff e Unit
7473

7574
foreign import data Element :: *
7675

@@ -612,9 +611,9 @@ foreign import bangbangFn
612611
\ var r = el[i]; \
613612
\ return angular.isDefined(r) ? just(r) : nothing; \
614613
\ }"
615-
:: Fn4 (Maybe Node) (Node -> Maybe Node) Element Number (Maybe Node)
614+
:: Fn4 (Maybe HTMLElement) (HTMLElement -> Maybe HTMLElement) Element Number (Maybe HTMLElement)
616615

617616
infixl 8 !!
618617

619-
(!!) :: Element -> Number -> Maybe Node
618+
(!!) :: Element -> Number -> Maybe HTMLElement
620619
(!!) = runFn4 bangbangFn Nothing Just

0 commit comments

Comments
 (0)