最近被问到了关于ADT的事情呢,于是想写一篇速通关于ADT、递归类型是怎么回事. 它面向了解过如何使用ADT,不过对ADT和递归类型的背后理论感兴趣的人,其他的部分我会尽可能self-contained.
more >>Frankenstein's blog
本文是POPL2022同名文章的中文翻译,無断転載禁止。
关于match types的Scala文档:https://docs.scala-lang.org/scala3/reference/new-types/match-types.html
Type-level programming在FP越来越流行,但type-level programming和subtyping的组合还没有充分的探索。这篇文章中的match types等价于类型层面的pattern matching,在基于system F$_{<:}$的一个演算上形式化了match type这个feature,证明了它的soundness。在Scala3的reference compiler上实现了match types的系统。
more >>本文为Type Theory and Formal Proof : An Introduction 的笔记,纯个人向(
之前我们从项$\lambda x:\sigma.x$中由类型变量抽象出$\lambda \alpha:\ast.\lambda x:\alpha.x$. 类似的,我们也可以从类型上抽象. 如类型$\beta\to\beta,\ \gamma\to\gamma,\ (\gamma\to\beta)\to(\gamma\to\beta),\ \dots$,都有$\Diamond\to\Diamond$这样的结构.
more >>本文为Type Theory and Formal Proof : An Introduction 的笔记,纯个人向(
对于抽象这个过程,我们有项$M$,其中可能有自由变量$x$,假设$x$有类型$\sigma$,我们从$M$中抽象$x$,可以得到项$\lambda x : \sigma.M$,同时,所有在$M$中的自由变量$x$被绑定了,我们说:
项$\lambda x:\sigma.M$依赖于项$x$.
因此,$\lambda{\to}$中可以构造依赖于项的项(terms depending on terms).
相应的是应用,对于$MN$的构造,我们可以把$M$应用到$N$,也得到一个项.
这称为一阶(first order)抽象,或一阶依赖,因为这个抽象是在项上进行的. 同时应用也是一阶的.
现在我们引入依赖于类型的项(terms depending on types),称二阶运算(second order operations)或二阶依赖(second order dependency).
得到的这一系统称二阶类型lambda演算(second order typed lambda calculus),或$\lambda 2$.
more >>本文为Type Theory and Formal Proof : An Introduction 的笔记,纯个人向(
我们从一个类型变量(type variables)的无限集开始:$\mathbb{V}=\lbrace \alpha,\beta,\gamma,…\rbrace$.
即 $\mathbb{T= V\ \mid\ T \to T}$ .
more >>本文为Type Theory and Formal Proof : An Introduction 的笔记,纯个人向(
对于函数的抽象,有两个构造方法和一个计算规则:
抽象(Abstraction)
由一个表达式$M$和一个变量$x$ 可以构造表达式$\lambda x.M$,称为$M$上$x$的抽象(abstraction of x over M)
应用(Application)
由表达式$M$和$N$可以构造表达式$M\ N$,称为$M$对$N$的应用(application of M to N)
Beta化简(β-reduction)
形如$(\lambda x.M)N$的表达式可以被改写成$M[x:=N]$,意思是表达式中的$M$中的每个$x$换成$N$,这一过程称为由$(\lambda x.M)N$到$M[x:=N]$的Beta化简(β-reduction).
注意“应用”仅是构造另一个lambda项的过程,而真正得到结果的过程则是“Beta化简”.
以下是严格定义
more >>单子是Haskell语言中较难理解的概念,本文将以简明的语言介绍这一概念及其应用,由于通俗性与严谨性不可兼顾,本文会牺牲一定的严谨性()。
Monad在Haskell中是一个类型类,中文通常翻译为单子,在GHC7.10以后它的定义如下:
1 | class Applicative m => Monad m where |
可以看出Monad是实现了一个(>>=)运算符的Applicative。而这个(>>=)运算符(Bind)类型古怪:它连接的左侧是一个Monad类型的值,右侧则是一个函数。
我们从最基本的例子开始。
Identity单子定义在Control.Monad.Identity中:
1 | newtype Identity a = Identity {runIdentity :: a} |
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia-plus根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true