git.iko.soy/rowtype-yoga/purescript-yoga-fetch-om
on main help sign in
rowtype-yoga/purescript-yoga-fetch-om/test/BodylessResponse.Example.purs
27 lines 763 B history raw
1-- Compile-time test: bodyless responses (e.g. 304, 401) can use {} without
2-- wrapping in { body :: {} }.
3module BodylessResponse.Example where
5import Prelude
7import Yoga.Fetch.Om (GET, Route, type (/), client)
8import Yoga.Om (Om)
10type Resource = { id :: Int, name :: String }
12type ResourceAPI =
13 { getResource ::
14 Route GET
15 ("resources" / "id")
16 {}
17 ( ok :: { body :: Resource }
18 , notModified :: {}
19 , unauthorized :: {}
20 )
21 }
23-- This must typecheck: the derived client exposes notModified/unauthorized as Unit errors.
24api
25 :: forall ctx err
26 . { getResource :: Om (Record ctx) (notModified :: Unit, unauthorized :: Unit | err) Resource }
27api = client @ResourceAPI "https://api.example.com"