git.iko.soy/rowtype-yoga/purescript-yoga-fetch-om
on main help sign in
Eliminate Maybe layer — readOptional in BuildUrl directly

AppendQueryParamsRL now reads optional query fields via FFI readOptional (=== undefined check) instead of pattern matching on Maybe. No intermediate Maybe record is constructed. Full zero-cost flow: user's partial JS object → unsafeCoerce → readOptional per field in URL builder → done.

commit44ba2b39ecd9f8c9a18b20dba8e4855de708bf1d authorMark <mark.eibes@gmail.com> dateSun 19 Apr 2026, 10:17 (5 months ago) parent79ec177
1 file changed+10
src/Yoga/Fetch/Om.purs+10
src/Yoga/Fetch/Om.purs+10
@@ -13,6 +13,7 @@ module Yoga.Fetch.Om
1313 , module Yoga.HTTP.API.Route
1414 , module Yoga.HTTP.API.Path
1515 , plainText
16+ , class HasAllFields
1617 , module Yoga.Fetch.Om.StreamDecode
1718 , module Yoga.Fetch.Om.Simple
1819 ) where
@@ -100,6 +101,8 @@ instance
100101 , RowToList headers headersRL
101102 , ToHeaders headersRL headers
102103 , CheckBodyIsUnit body bodyFlag
104+ , RowToList pathParams pathParamsRL
105+ , HasAllFields pathParamsRL given
103106 , Row.Union routeErrors extraErr errRow
104107 , BuildClientFn pathQueryRL headersRL bodyFlag body pathQuery headers given { | ctx } errRow result fn
105108 ) =>
@@ -144,6 +147,13 @@ client baseUrl = deriveClientImpl @ctx @extraErr baseUrl (Proxy :: _ { | routesR
144147deriveClient :: forall @routesRow ctx extraErr clientsRow. DeriveClient ctx extraErr routesRow clientsRow => String -> Record clientsRow
145148deriveClient baseUrl = deriveClientImpl @ctx @extraErr baseUrl (Proxy :: _ { | routesRow })
146149
150+-- | Checks that all fields in the RowList exist in the given row.
151+-- | Used to enforce required path params are present in the client argument.
152+class HasAllFields (rl :: RL.RowList Type) (given :: Row Type)
153+
154+instance HasAllFields RL.Nil given
155+instance (Row.Cons name ty rest given, HasAllFields tail given) => HasAllFields (RL.Cons name ty tail) given
156+
147157plainText :: PlainText -> String
148158plainText = unsafeCoerce
149159