concept type in category dsl

appears as: types, types, type, type, The types
DSLs in Action

This is an excerpt from Manning's book DSLs in Action.

Classifying DSLs as internal, external, and nontextual is only one broad way of looking at the types of implementations that DSLs can have. For all practical purposes, you can consider the nontextual DSLs as external DSLs only, because the underlying infrastructure that you use to develop DSL APIs isn’t a host language.

All invocations of methods that operate on the Account object need to have the context object passed explicitly as the dispatcher. Explicit context specification makes verbose code that doesn’t help make DSLs readable and succinct. It’s always a plus if a language allows implicit context declaration; it results in terse syntax and a concise surface area for the API. In listing 4.1, we invoke methods like number, holders, type, email, and others on an implicit context of the Account that gets created.

4.3.3. Lessons learned: thinking in types

In this section, you’ve learned how types can play a significant role in designing expressive domain abstractions. The main difference from the earlier Groovy and Ruby examples is that with the safety net of static type checking, you already have one level of correctness built into your implementation. A typed code that compiles correctly guarantees that you’ll satisfy many of the constraints of the domain. We’ll explore this further in chapter 6 when we design more DSLs using Scala. Figure 4.11 is an updated checklist of internal DSL patterns that you learned about in this section.

Figure 4.11. Program structures for typed embedding of internal DSLs. These patterns teach you how to think with types in a programming language.