Make function call tail-call optimized.

This commit is contained in:
Dillon Kearns 2021-07-29 10:06:46 -07:00
parent 820198bbc2
commit 4e0c4d3fe6

View File

@ -250,11 +250,11 @@ resolve appType request rawResponses =
resolveUrls : ApplicationType -> RawRequest value -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request)
resolveUrls appType request rawResponses =
resolveUrlsHelp appType request rawResponses []
resolveUrlsHelp appType rawResponses [] request
resolveUrlsHelp : ApplicationType -> RawRequest value -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request) -> List (Secrets.Value Pages.StaticHttp.Request.Request)
resolveUrlsHelp appType request rawResponses soFar =
resolveUrlsHelp : ApplicationType -> RequestsAndPending -> List (Secrets.Value Pages.StaticHttp.Request.Request) -> RawRequest value -> List (Secrets.Value Pages.StaticHttp.Request.Request)
resolveUrlsHelp appType rawResponses soFar request =
case request of
RequestError error ->
case error of
@ -266,13 +266,10 @@ resolveUrlsHelp appType request rawResponses soFar =
soFar
Request _ ( urlList, lookupFn ) ->
lookupFn KeepOrDiscard.Keep appType rawResponses
|> (\nextRequest ->
resolveUrlsHelp appType
nextRequest
rawResponses
(soFar ++ urlList)
)
resolveUrlsHelp appType
rawResponses
(soFar ++ urlList)
(lookupFn KeepOrDiscard.Keep appType rawResponses)
Done _ _ ->
soFar