Dependent type是一种依赖于值的类型,它增强了类型表达能力,让我们可以构造更强大的类型定义,无论用在定理证明还是用在减少程序出错的可能都是极好的。 本文我们讨论在Haskell中如何合理使用扩展模拟Dependent type。 入门级LIST 让我们先从一个简单的List开始,看看没有dependent type的时候,会发生什么。 先定义自然数...
GADT可以看作是Haskell在支持dependent type的方向上的一步。有人甚至实现了使用GADT模拟dependent type的方法:www.cs.virginia.edu/~jba5b/singleton,不过我没有看他的paper。 赞 回复 lichray 2008-03-02 16:44:40 注意这一句: In dependent type theory there is no distinction between types and values....
Data.Singletons.Decide (from singletons) exports type classes for propositional equality. See the "Equality classes" section for more information.Data.Singletons.TH (from singletons-th) exports all the definitions needed to use the Template Haskell code to generate new singletons. Data.Singletons...
denttypescanbesimulatedinHaskell.Ontheotherhand,weidentify severalproblematicissueswithsuchasimulationtechniqueandthen suggestsomeapproachestoaddressingtheseissuesinHaskell. 1Introduction ThetypesystemofHaskell,whichwasoriginallybasedontheHindley-Milner typesystem[13],hassinceevolvedsignificantly.Withvariousadditions...
On the one hand, we present an interesting (and somewhat unexpected) application of the current type system of Haskell, illustrating through a concrete example how some typical use of dependent types can be simulated in Haskell. On the other hand, we identify several problematic issues with such...
在类型与值分立的非依赖类型(non-dependent type)编程语言中,我们有时能省略类型信息,以令编译器(类型检查器)推导省略的类型,就像你在Haskell里(或在更弱的类型系统中,如Kotlin或C#的)做的一样。 在语言有依赖类型(is dependently-typed)的情况下,状况稍有不同。因为它们书写参数多态(parametrically-polymorphic)函...
haskellsingletondependent-typedata-kinds 3 在singleton库方面,我是个新手,也许我这里尝试的有点过头了。我已经成功地使用 fromSing 将“singleton类型”转换为“值级别术语”(我的术语是否正确?),但我无法理解如何使用toSing,并且从概念上讲,它会如何在运行时将值转换为类型?以下...
Examples in- clude meta-ML (for meta-programming) [32], PolyP [18] and Generic Haskell [17] (for generic programming), and dependent ML [29] (for programming with “indexed” types). It turns out that many of these features can be modelled by the dependent types in the strong type ...
In these lecture notes we give an introduction to functional programming with dependent types. We use the dependently typed programming language Agda which is an extension of Martin-Löf type theory. First we show how to do simply typed functional programming in the style of Haskell and ML. ...
Conversely, others, such as DML, ATS, Ωmega, or Haskell, allow nonterminating computation, but do not allow those terms to appear in types. Instead, they identify a terminating index language and use singleton types to connect indices to computation. In both cases, decidable type checking ...