git.iko.soy/rowtype-yoga/purescript-yoga-fetch-om
on main help sign in
Replace PlainText with PlainTextResponse phantom type
commitbc4672a6433234b5f245af6254285599753de525 authorMark <mark.eibes@gmail.com> dateSun 8 Feb 2026, 15:18 (8 months ago) parentd2a8658
2 files changed+9−8
src/Yoga/Fetch/Om/Simple.purs+8−6 test/Simple.Spec.purs+1−2
src/Yoga/Fetch/Om/Simple.purs+8−6
@@ -40,7 +40,7 @@ import JS.Fetch.RequestMode as Mode
4040import JS.Fetch.Response as Resp
4141import Promise.Aff as Promise
4242import Type.Row.Homogeneous (class Homogeneous)
43−import Yoga.HTTP.API.Route.Encoding (PlainText)
43+-- PlainText removed, using local phantom type
4444import Yoga.JSON (class ReadForeign, class WriteForeign, readJSON_, writeJSON)
4545import Yoga.Om (Om, fromAff, throw)
4646
@@ -52,7 +52,9 @@ class DecodeResponse :: forall k. k -> Type -> Constraint
5252class DecodeResponse a result | a -> result where
5353 decodeResponse :: String -> Maybe result
5454
55−instance DecodeResponse (PlainText String) String where
55+data PlainTextResponse
56+
57+instance DecodeResponse PlainTextResponse String where
5658 decodeResponse = Just
5759
5860else instance ReadForeign a => DecodeResponse a a where
@@ -145,7 +147,7 @@ delete_
145147 => Record headers
146148 -> String
147149 -> Om ctx (fetchError :: FetchError | err) Unit
148−delete_ headers url = void $ simpleFetch @(PlainText String) DELETE headers url Nothing
150+delete_ headers url = void $ simpleFetch @PlainTextResponse DELETE headers url Nothing
149151
150152post
151153 :: forall @a result headers body ctx err
@@ -177,7 +179,7 @@ post_
177179 -> String
178180 -> body
179181 -> Om ctx (fetchError :: FetchError | err) Unit
180−post_ headers url body = void $ simpleFetch @(PlainText String) POST headers url (Just (writeJSON body))
182+post_ headers url body = void $ simpleFetch @PlainTextResponse POST headers url (Just (writeJSON body))
181183
182184put
183185 :: forall @a result headers body ctx err
@@ -209,7 +211,7 @@ put_
209211 -> String
210212 -> body
211213 -> Om ctx (fetchError :: FetchError | err) Unit
212−put_ headers url body = void $ simpleFetch @(PlainText String) PUT headers url (Just (writeJSON body))
214+put_ headers url body = void $ simpleFetch @PlainTextResponse PUT headers url (Just (writeJSON body))
213215
214216patch
215217 :: forall @a result headers body ctx err
@@ -241,4 +243,4 @@ patch_
241243 -> String
242244 -> body
243245 -> Om ctx (fetchError :: FetchError | err) Unit
244−patch_ headers url body = void $ simpleFetch @(PlainText String) PATCH headers url (Just (writeJSON body))
246+patch_ headers url body = void $ simpleFetch @PlainTextResponse PATCH headers url (Just (writeJSON body))
test/Simple.Spec.purs+1−2
@@ -4,7 +4,6 @@ import Prelude
44
55import Effect.Class.Console (log)
66import Yoga.Fetch.Om.Simple (FetchError, FetchResponse, get, getWithHeaders, post, post_, put, put_, patch, patch_, delete, delete_)
7−import Yoga.HTTP.API.Route.Encoding (PlainText)
87import Yoga.Om (Om, handleErrors)
98
109type User = { id :: Int, name :: String, email :: String }
@@ -17,7 +16,7 @@ exampleGetWithAuth :: forall ctx err. Om ctx (fetchError :: FetchError | err) Us
1716exampleGetWithAuth = get @User { authorization: "Bearer abc123" } "https://api.example.com/users/42"
1817
1918exampleGetPlainText :: forall ctx err. Om ctx (fetchError :: FetchError | err) String
20−exampleGetPlainText = get @(PlainText String) {} "https://api.example.com/health"
19+exampleGetPlainText = get @String {} "https://api.example.com/health"
2120
2221exampleGetWithHeaders :: forall ctx err. Om ctx (fetchError :: FetchError | err) (FetchResponse User)
2322exampleGetWithHeaders = do