Design patterns for static type checking
I'm currently trying to figure out which aspects of my program can be statically type checked by the scala compiler. After reading this question I came up with the idea of design patterns for types. I find it pretty complicated to get my head around what might be possible with Scala's type system. So I'd like to look at practical usages (not peano arithmetic or stuff like that). Simple patterns that reappear often in normal code.
Does anyone know of any blogs or even books that deal with this question? Preferably in Scala, but it might also be useful for other languages.
I think one of the most useful things that would deserve the name "design pattern" is the "phantom types" technique. It is a more-or-less-systematic way to encode static information in a type parameter. See some examples :
You may also be interested in a related Oleg wondertrick : Lightweight static capabilities (with Chung-chieh Shan).
You might look at the design advice for Haskell, and specifically, some of the more recent research papers on embedding strong properties into the type system:
There's no standard methodologies here yet, though there are many many nice examples of individual problems.
链接地址: http://www.djcxy.com/p/42874.html下一篇: 静态类型检查的设计模式