静态类型检查的设计模式 [英] Design patterns for static type checking

查看:116
本文介绍了静态类型检查的设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚我的程序的哪些方面可以被scala编译器静态地输入。阅读此问题后,我想出了类型的设计模式的想法。我发现使用Scala的类型系统来解决可能的问题非常复杂。所以我想看看实际的用法(不是peano算术或类似的东西)。简单的模式经常在正常的代码中出现。

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.

有谁知道处理这个问题的任何博客甚至是书?最好在Scala中,但它也可能对其他语言有用。

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 :

  • Haskell wiki
  • an OCaml blog
  • a Haskell blog

您可能还对相关的Oleg wondertrick感兴趣:轻量级静态功能(与Chung-chieh Shan)。

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

这篇关于静态类型检查的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆