3

In the following function definition:

app :: Application
app _ respond = do
    putStrLn "I've done some IO here"
    respond $ responseLBS
        status200
        [("Content-Type", "text/plain")]
        "Hello, Web!"

Hello the app function doesn't seem to take arguments. Why in the above example there are two arguments?

1

1 Answer 1

8

Application is a type synonym. It is defined as:

type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived

It is thus a function that takes a Request, and a function that maps an Response on an IO ResponseReceived, and then produces an IO ResponseReceived. Usually such functions produce a Response that is then post-processed by the response.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.