Refactor as a step for tail call optimization.

This commit is contained in:
Dillon Kearns 2021-06-03 11:15:57 -07:00
parent f595605f4d
commit 83eb90aa9f

View File

@ -144,14 +144,11 @@ map fn requestInfo =
Request partiallyStripped Request partiallyStripped
( urls ( urls
, \appType rawResponses -> , \appType rawResponses ->
lookupFn appType rawResponses map fn (lookupFn appType rawResponses)
|> (\nextRequest ->
map fn nextRequest
)
) )
Done stripped value -> Done stripped value ->
fn value |> Done stripped Done stripped (fn value)
{-| Helper to remove an inner layer of Request wrapping. {-| Helper to remove an inner layer of Request wrapping.
@ -233,16 +230,12 @@ map2 fn request1 request2 =
RequestError error RequestError error
( Request newDict1 ( urls1, lookupFn1 ), Request newDict2 ( urls2, lookupFn2 ) ) -> ( Request newDict1 ( urls1, lookupFn1 ), Request newDict2 ( urls2, lookupFn2 ) ) ->
let Request (combineReducedDicts newDict1 newDict2)
value : ApplicationType -> RequestsAndPending -> DataSource c ( urls1 ++ urls2
value appType rawResponses = , \appType rawResponses ->
case ( lookupFn1 appType rawResponses, lookupFn2 appType rawResponses ) of case ( lookupFn1 appType rawResponses, lookupFn2 appType rawResponses ) of
( newValue1, newValue2 ) -> ( newValue1, newValue2 ) ->
map2 fn newValue1 newValue2 map2 fn newValue1 newValue2
in
Request (combineReducedDicts newDict1 newDict2)
( urls1 ++ urls2
, value
) )
( Request dict1 ( urls1, lookupFn1 ), Done stripped2 value2 ) -> ( Request dict1 ( urls1, lookupFn1 ), Done stripped2 value2 ) ->