Skip to content

Commit 5b0d4fe

Browse files
author
Kazuki Okamoto
committed
haskell-2019
1 parent 861224a commit 5b0d4fe

File tree

2 files changed

+266
-0
lines changed

2 files changed

+266
-0
lines changed
258 Bytes
Loading
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
---
2+
title: Haskell Symposium 2019 レポート
3+
subHeading: ""
4+
headingBackgroundImage: ../../img/2019/haskell-symposium/background.png
5+
headingDivClass: post-heading
6+
author: Kazuki Okamoto
7+
postedBy: <a href="https://twitter.com/kakkun61">Kazuki Okamoto (@kakkun61)</a>
8+
date: September 28, 2019
9+
tags: ICFP, Haskell Symposium
10+
---
11+
12+
Haskell Symposium 2019にIIJとして参加してきました。
13+
14+
聴講した発表についての概要をまとめましたので、どの論文を読んでみるか決めるなどの際にご活用ください。内容については私の聞きまちがい・読みまちがいなどあると思いますのでご了承ください。
15+
16+
# Bidirectional Type Class Instances
17+
18+
- Koen Pauwels (KU Leuven), Georgios Karachalias (KU Leuven), Michiel Derhaeg (Guardsquare), Tom Schrijvers (KU Leuven)
19+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/8/Bidirectional-Type-Class-Instances>
20+
- <https://arxiv.org/abs/1906.12242>
21+
22+
GADTと型クラスはそれぞれ便利だが混ぜると問題が起きる場合がある。
23+
24+
次のような`Term`があるとき、その`Show`インスタンスを考える。
25+
26+
```haskell
27+
data Term :: Type -> Type where
28+
Con :: a -> Term a
29+
Tup :: Term b -> Term c -> Term (b, c)
30+
```
31+
32+
次のように`Show`インスタンスを定義すると型エラーになる
33+
34+
```haskell
35+
instance Show a => Show (Term a) where
36+
show (Con a) = show a
37+
show (Tup x y) = unwords ["(", show x, ",", show y, ")"]
38+
```
39+
40+
```
41+
Could not deduce (Show b) arising from a use of `show'
42+
from the context (Show a) or from (a ~ (b, c))
43+
```
44+
45+
これは`Show (b, c)`ならば`Show b`という関係がないために起こる。
46+
47+
一方タプルについての`Show`は、`Show a`かつ`Show b`ならば`Show (a, b)`という関係である。
48+
49+
```haskell
50+
instance (Show a, Show b) => Show (a, b) where
51+
52+
```
53+
54+
この「ならば」を両方向にすれば問題は解決できるのではないかというのが、この論文の主張である。
55+
56+
# Generic and Flexible Defaults for Verified, Law-Abiding Type-Class Instances
57+
58+
- Ryan Scott (Indiana University), Ryan R. Newton (Indiana University)
59+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/3/Generic-and-Flexible-Defaults-for-Verified-Law-Abiding-Type-Class-Instances>
60+
- <https://ryanglscott.github.io/papers/verified-classes.pdf>
61+
62+
型クラスの法則は依存型を使えば証明できるが、インスタンスごとに書くのはめんどうなので`Generics`で出来るようにしようという話である。
63+
64+
# Modular effects in Haskell through effect polymorphism and explicit dictionary applications - A new approach and the μVeriFast verifier as a case study
65+
66+
- Dominique Devriese (Vrije Universiteit Brussel)
67+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/1/Modular-effects-in-Haskell-through-effect-polymorphism-and-explicit-dictionary-applic>
68+
69+
様々な種類の効果が複雑に絡み合うアプリケーションを整理するために、「効果を伴う処理を持った辞書」を明示的に渡す方式の提案である。
70+
71+
提案した方式によってVeriFastを再実装してみることで、実際に発生した問題と解決方法を解説している。
72+
73+
# Verifying Effectful Haskell Programs in Coq
74+
75+
- Jan Christiansen (Flensburg University of Applied Sciences), Sandra Dylus (University of Kiel), Niels Bunkenburg (University of Kiel)
76+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/4/Verifying-Effectful-Haskell-Programs-in-Coq>
77+
- <https://dl.acm.org/citation.cfm?id=3342592>
78+
79+
Coqによる、効果を伴うプログラムの証明に関する話。
80+
81+
効果について直接証明することはせず、Freeモナドを用いての証明を試みても、そのままCoqに翻訳すると停止性チェックによってエラーになってしまう。
82+
83+
そのために行った工夫に加え、具体例として、`trace`や(部分関数による)エラーなど、Haskellにおいて暗黙に発生する効果を考慮したモデル化について検討した。
84+
85+
# Solving Haskell equality constraints using Coq
86+
87+
- Zubin Duggal
88+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/15/Solving-Haskell-equality-constraints-using-Coq>
89+
90+
data kindsやtype familiesといったGHC拡張によって厳格なデータ型を定義できるが、それに対する操作を定義するとGHCには解けない型レベルの等式が生成されることがある。
91+
92+
制約カインドの型に対する型クラスとして`Proven`を提供し、この制約がある箇所をGHC型検査プラグインが検出して対応するCoqコードのテンプレートを生成する。
93+
94+
そのCoqコードに証明がなければ警告を表示する。
95+
96+
```haskell
97+
type ProofName = Symbol
98+
99+
class c => Proven (prf :: ProofName) (c :: Constraint)
100+
where {}
101+
102+
applyProof :: forall prf c a. Proven prf c => (c => a) -> a
103+
applyProof x = x
104+
105+
lemma3 = applyProof @"nonzero_pop" @(NNonZero (Popcount b) ~ True) Refl
106+
```
107+
108+
いくつか制約があるがHaskellの型をCoqに自動的に変換している。
109+
110+
# Formal Verification of Spacecraft Control Programs: An Experience Report
111+
112+
- Andrey Mokhov (Newcastle University), Georgy Lukyanov (Newcastle University), Jakob Lechner (RUAG Space Austria GmbH)
113+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/5/Formal-Verification-of-Spacecraft-Control-Programs-An-Experience-Report>
114+
- <https://dl.acm.org/citation.cfm?id=3342593>
115+
116+
REDFINという固定小数演算と整数演算のための処理系があるのだが、そのアセンブリーコードに対して形式検証をしたという報告である。
117+
118+
# G2Q: Haskell Constraint Solving
119+
120+
- William T. Hallahan (Yale University), Anton Xue (Yale University), Ruzica Piskac (Yale University)
121+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/2/G2Q-Haskell-Constraint-Solving>
122+
- <https://dl.acm.org/citation.cfm?id=3342590>
123+
124+
G2QはHaskellのソースにquasi quoteで埋め込むDSLである。
125+
126+
Haskellで書いた条件式をsymbolic executionして、SMT solverに渡す式に変換して、SMT solverに条件を満たす関数を導出させる。
127+
128+
# Making a Faster Curry with Extensional Types
129+
130+
- Paul Downen (University of Oregon), Zachary Sullivan, Zena M. Ariola (University of Oregon), Simon Peyton Jones (Microsoft)
131+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/6/Making-a-Faster-Curry-with-Extensional-Types>
132+
- <https://ix.cs.uoregon.edu/~pdownen/publications/eta.pdf>
133+
134+
パフォーマンスのためにη変換してほしいところを明示したいことがある。
135+
136+
例えば、次のような意味論上は等価な関数`f1``f2`があるとする。
137+
138+
```haskell
139+
f1 = \x -> let z = h x x in \y -> e y z
140+
f2 = \x -> \y -> let z = h x x in e y z
141+
```
142+
143+
実際は`f1`は引数`x`を取った後クロージャー生成のためにヒープ確保するのに対して、`f2`はアリティが2の関数と解釈されて中間のクロージャーが必要なくなる。
144+
145+
`~>`というアリティの情報を持った関数型を新たに導入して`->`の代わりに使えるようにする。
146+
147+
`TYPE (a :: RuntimeRep (FunRep 2))`というような新たなポリモーフィズムを導入する。ここでの`2`がアリティ。
148+
149+
`Int`に対して`Int#`があるように基本的にはパフォーマンスが必要なライブラリーなど内部的に使用する想定。
150+
151+
# Multi-Stage Programs in Context
152+
153+
- Matthew Pickering (University of Bristol), Nicolas Wu (Imperial College London), Csongor Kiss (Imperial College London)
154+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/9/Multi-Stage-Programs-in-Context>
155+
- <https://dl.acm.org/citation.cfm?id=3342597>
156+
157+
次のような準引用があったときに、組み合わせると元々あったはずの情報が欠落する場合がある。
158+
159+
```haskell
160+
qshow :: Code (Int -> String)
161+
qshow = [q| show |]
162+
163+
qread :: Code (String -> Int)
164+
qread = [q| read |]
165+
166+
trim :: Code (String -> String)
167+
trim = [q| $(qshow) . $(qread) |]
168+
```
169+
170+
`qshow``qread`にあった`Int`という情報が、組み合わせて`trim`とすると欠落してコンパイルエラーになってしまう。
171+
172+
spliceするときにHaskellソースコードの構文木ではなくCoreに対するものを出力すればそれは型が明示されているし問題がない。
173+
174+
しかも、splice後の型検査を省略できるのでコンパイルの高速化にも寄与する。
175+
176+
# Working with Source Plugins
177+
178+
- Matthew Pickering (University of Bristol), Nicolas Wu (Imperial College London), Boldizsár Németh (Eötvös Loránd University)
179+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/11/Working-with-Source-Plugins>
180+
- <https://dl.acm.org/citation.cfm?id=3342599>
181+
182+
souce pluginsのしくみや、書き方、実装時のテクニックの紹介である。
183+
184+
# STCLang: State Thread Composition as a Foundation for Monadic Dataflow Parallelism
185+
186+
- Sebastian Ertel, Justus Adam (Technische Universität Dresden), Norman A. Rink (TU Dresden), Andrés Goens, Jeronimo Castrillon (TU Dresden)
187+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/12/STCLang-State-Thread-Composition-as-a-Foundation-for-Monadic-Dataflow-Parallelism>
188+
- <https://dl.acm.org/citation.cfm?id=3342600>
189+
190+
不聴講
191+
192+
# Synthesizing Functional Reactive Programs
193+
194+
- Bernd Finkbeiner, Felix Klein (Saarland University), Ruzica Piskac (Yale University, Mark Santolucito (Yale University)
195+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/13/Synthesizing-Functional-Reactive-Programs>
196+
- <https://dl.acm.org/citation.cfm?id=3342601>
197+
198+
不聴講
199+
200+
# The essence of live coding: Change the program, keep the state!
201+
202+
- Manuel Bärenz (sonnen eServices GmbH)
203+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/14/The-essence-of-live-coding-Change-the-program-keep-the-state->
204+
205+
不聴講
206+
207+
# Monad Transformers and Modular Algebraic Effects: What Binds Them Together
208+
209+
- Tom Schrijvers (KU Leuven), Maciej Piróg (University of Wrocław), Nicolas Wu (Imperial College London), Mauro Jaskelioff (CONICET)
210+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/7/Monad-Transformers-and-Modular-Algebraic-Effects-What-Binds-Them-Together>
211+
- <https://dl.acm.org/citation.cfm?id=3342595>
212+
213+
モナドトランスフォーマーと代数的効果との対比である。
214+
215+
モナドトランスフォーマーから代数的効果への変換またその逆のときにどういう手法があって、それぞれを構成する要素がどう対応しているかを説明している。
216+
217+
モナドトランスフォーマーと代数的効果だとモナドトランスフォーマーの方が表現できるものが大きいのでモナドトランスフォーマーから代数的効果へはどんなものでも変換できるわけではない。
218+
219+
例えば`catch``local`は代数的効果にできない。
220+
221+
# Scoping Monadic Relational Database Queries
222+
223+
- Anton Ekblad (Chalmers University of Technology)
224+
- <https://icfp19.sigplan.org/details/haskellsymp-2019-papers/10/Scoping-Monadic-Relational-Database-Queries>
225+
- <https://dl.acm.org/citation.cfm?id=3342598>
226+
227+
モナドはHaskell界隈で非常に普及しているのでSQLに対するEDSLとしてモナドの構造を採用したい。
228+
229+
このときSQLの結合を表現すると、SQLとしてはスコープ外にもかかわらずEDSLとしてはスコープ内となって使える変数ができてしまう。
230+
231+
これをEDSLとしてもエラーとしたい。
232+
233+
例えば、次のような例で実行時エラーとなってしまう。ここで`a0``tableA`の列とする。
234+
235+
```SQL
236+
SELECT a0, b0
237+
FROM
238+
tableA
239+
LEFT JOIN
240+
(SELECT b0 FROM tableB WHERE a0 == b1)
241+
ON tableA.a2 == tableb.b2
242+
```
243+
244+
`SELECT b0 FROM tableB WHERE a0 == b1`の部分でスコープ外の`a0`を参照しているためエラーとなる。
245+
246+
単純なモナドEDSLだと次のようになりコンパイルが通る。
247+
248+
```haskell
249+
do
250+
a0 :*: a1 :*: a2 <- from table0
251+
leftJoin $ do
252+
b0 :*: b1 :*: b2 <- from table1
253+
ristrict $ a0 .== b1
254+
on $ a2 .== b2
255+
```
256+
257+
`ristrict $ a0 .== b1`の部分において`a0`はHaskellとしてはスコープ内にある。
258+
259+
この問題を次のような型レベル関数を駆使することでEDSLにおいてもコンパイル時エラーとすることができた。
260+
261+
```haskell
262+
type family Cols a
263+
type family Outer a
264+
type family UnAggr a
265+
type family FromRow a
266+
```

0 commit comments

Comments
 (0)