资 源 简 介
One of Haskell’s most outstanding features is it’s type-checker. Mis-matching types are a quick indication that something is wrong with a particular piece of code. And type annotations are useful documentation tool that provides hints about the uses of a function. Type checking is however not unique to programming languages. There is a similar concept in Physics: Units. Some programming languages, such as Mathematica provide built-in unit-checking. The Haskell language lends itself to this purpose very nicely, due to it’s type-checking system. As opposed to Mathematica, this can be done without changes to the core language itself.
This post will start out by introducing simple type arithmetic using Peano numerals and progresses to implementing a full unit checker on top of the Haskell language...
Read the rest >>
请点击左侧文件开始预览 !预览只提供20%的代码片段,完整代码需下载后查看 加载中 侵权举报