Chapter 6. Internal DSL design in Scala
This chapter covers
- Scala as a language
- Developing an internal DSL in Scala
- Composing multiple DSLs
- Using monadic structures
In the earlier chapters, we’ve been through the pros and cons of DSL-driven development. By now you must have realized that for the parts of your application that need to model business rules, a DSL can go a long way toward improving the communication path between the development team and the team of domain experts. In the last chapter, we discussed how you can use a few of the dynamic languages on the JVM as hosts for designing internal DSLs. In this chapter, we’ll look at the most promising candidate from among the statically typed ones, Scala.
Like all implementation discussions, this is going to be a programming-intensive chapter in which we’ll start with the suitability of Scala as a host for implementing internal DSLs, and then dive right into real-world DSL design. Figure 6.1 is a roadmap of our journey through this chapter.