Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 92a520a

Browse files
committed
updates for aff-4.0 and use purescript-records
1 parent 23d24a6 commit 92a520a

File tree

5 files changed

+12
-68
lines changed

5 files changed

+12
-68
lines changed

bower.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
"url": "git://github.com/paf31/purescript-quickserve.git"
1313
},
1414
"dependencies": {
15-
"purescript-aff": "^3.1.0",
15+
"purescript-aff": "^4.0.0",
1616
"purescript-node-http": "^4.0.0",
17-
"purescript-foreign-generic": "^4.1.0",
18-
"purescript-typelevel-prelude": "^2.3.0"
17+
"purescript-foreign-generic": "^5.0.0",
18+
"purescript-typelevel-prelude": "^2.4.0",
19+
"purescript-record": "^0.2.3"
1920
}
2021
}

generated-docs/QuickServe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Newtype Capture _
193193

194194
``` purescript
195195
class ServableList eff (l :: RowList) (r :: # Type) | l -> r where
196-
serveListWith :: LProxy l -> { | r } -> Request -> Response -> List String -> Maybe (Eff (http :: HTTP | eff) Unit)
196+
serveListWith :: RLProxy l -> { | r } -> Request -> Response -> List String -> Maybe (Eff (http :: HTTP | eff) Unit)
197197
```
198198

199199
##### Instances

generated-docs/QuickServe/Internal.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/QuickServe.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Control.Monad.Eff.Ref.Unsafe (unsafeRunRef)
3333
import Control.Monad.Eff.Unsafe (unsafeCoerceEff)
3434
import Control.Monad.Except (runExcept)
3535
import Data.Bifunctor (bimap)
36-
import Data.Either (Either(..))
36+
import Data.Either (Either(..), either)
3737
import Data.Foreign (renderForeignError)
3838
import Data.Foreign.Class (class Decode, class Encode)
3939
import Data.Foreign.Generic (decodeJSON, encodeJSON)
@@ -42,15 +42,15 @@ import Data.Maybe (Maybe(Nothing, Just), maybe)
4242
import Data.Monoid (mempty)
4343
import Data.Newtype (class Newtype, unwrap, wrap)
4444
import Data.Nullable (toMaybe)
45+
import Data.Record (get)
4546
import Data.String (split)
4647
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
4748
import Node.Encoding (Encoding(..))
4849
import Node.HTTP (HTTP, ListenOptions, Request, Response, createServer, listen, requestAsStream, requestMethod, requestURL, responseAsStream, setHeader, setStatusCode, setStatusMessage)
4950
import Node.Stream (end, onDataString, onEnd, onError, writeString)
5051
import Node.URL (parse)
51-
import QuickServe.Internal (LProxy(..), get, rowToList)
5252
import Type.Proxy (Proxy(..))
53-
import Type.Row (class RowToList, Cons, Nil, kind RowList)
53+
import Type.Row (class RowToList, Cons, Nil, RLProxy(..), kind RowList)
5454
import Unsafe.Coerce (unsafeCoerce)
5555

5656
-- | A type class for types of values which define
@@ -179,7 +179,7 @@ instance servableMethod
179179
let actual = requestMethod req
180180
expected = reflectSymbol (SProxy :: SProxy method)
181181
if actual == expected
182-
then void $ runAff handleError handleResponse (unwrap respond)
182+
then void $ runAff (either handleError handleResponse) (unwrap respond)
183183
else sendError res 405 "Method not allowed" ("Expected " <> expected)
184184
serveWith _ _ _ _ = Nothing
185185

@@ -265,11 +265,11 @@ badRoute :: forall eff. Response -> Eff (http :: HTTP | eff) Unit
265265
badRoute res = sendError res 400 "Bad Request" "No such route"
266266

267267
instance servableRecord :: (RowToList r l, ServableList eff l r) => Servable eff (Record r) where
268-
serveWith r = serveListWith (rowToList r) r
268+
serveWith r = serveListWith (RLProxy :: RLProxy l) r
269269

270270
class ServableList eff (l :: RowList) (r :: # Type) | l -> r where
271271
serveListWith
272-
:: LProxy l
272+
:: RLProxy l
273273
-> Record r
274274
-> Request
275275
-> Response
@@ -285,4 +285,4 @@ instance servableListCons
285285
serveListWith _ rec req res (actual : xs)
286286
| actual == reflectSymbol (SProxy :: SProxy route)
287287
= serveWith (get (SProxy :: SProxy route) rec :: s) req res xs
288-
serveListWith _ rec req res xs = serveListWith (LProxy :: LProxy l) (unsafeCoerce rec) req res xs
288+
serveListWith _ rec req res xs = serveListWith (RLProxy :: RLProxy l) (unsafeCoerce rec) req res xs

src/QuickServe/Internal.purs

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)