Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design patterns for static type checking [closed]

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.

like image 788
ziggystar Avatar asked Apr 06 '11 12:04

ziggystar


1 Answers

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 :

  • Haskell wiki
  • an OCaml blog
  • a Haskell blog

You may also be interested in a related Oleg wondertrick : Lightweight static capabilities (with Chung-chieh Shan).

like image 56
gasche Avatar answered Sep 18 '22 17:09

gasche