Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

IV. Appendices > D. Settings Types

Appendix D. Settings Types

Let’s say you’re writing a web server. You want the server to take a port to listen on, and an application to run. So you create the following function:

run :: Int -> Application -> IO ()

But suddenly you realize that some people will want to customize their timeout durations. So you modify your API:

run :: Int -> Int -> Application -> IO ()

So, which Int is the timeout, and which is the port? Well, you could create some type aliases, or comment your code. But there’s another problem creeping into our code: this run function is getting unmanageable. Soon we’ll need to take an extra parameter to indicate how exceptions should be handled, and then another one to control which host to bind to, and so on.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint