- Haskellにおける型レベルプログラミングの基本(翻訳) - Qiita
- [1610.07978] Dependent Types in Haskell: Theory and Practice
- Gauging Interest in a Type-Level Programming Book
- Kwang’s Haskell Blog - Type-level insertion sort
- GHC.TypeLits
- Testing a type for (Eq a) in Haskell
- Polymorphism within higher-order functions?
- What Are Impredicative Types?
- A SIMPLE PROBLEM WITH RECURSIVE TYPES AND SUBTYPING
- Haskellのforallについて理解したことを書いておく(ランクN多相限定)。
- Is there a function to flatten a nested list of elements?
- TYPE COMPREHENSION
- k0001/exinst
- 関西関数型道場 - 第参回 S3 「型レベルプログラミング」
- Predicates, Trees and GADTs
- 24 Days of GHC Extensions: Type Operators
- Applying Type-Level and Generic Programming in Haskell
- Djinn, a theorem prover in Haskell, for Haskell.
- The type-combinators package
- Typing Haskell in Haskell
- type roleについて学ぶ
- 7.27. Roles
- Generative Type Abstraction and Type-level Computation
- 型推論のしくみ
- thihの解析に進捗があります
- 型クラスを含んだ型推論を概観する 〜Typing Haskell in Haskell より〜
- System F をHaskellとPythonで実装した
- Decidable Propositional Equality in Haskell
- 型レベル自然数(つよい)
- 型レベルで平衡が保証される探索木
- Filling Haskell’s Type Holes Like It’s Agda
- siddharthist/CoverTranslator - A tool for formally verifying Haskell code in Agda
- Dimensional - Douglas McClean - Boston Haskell
- Promoting the arrow type
- 100 Days of Fibonacci - Day 9, Haskell Types
- Embedding Monomorphic Haskell Functions in a Dynamic Language With Similiar Semantics
- Tuples as heterogeneous lists
- Type safe Polyvariadic functions in Haskell
- ‘There and Back Again’ and What Happened After
- Coinductiveのintro rule
- Understanding typing judgments
- Frobenius property of weak factorisation systems and Pi-types
- Vorlesung 1: Typen und Typtheorie - FFPiHaskell (16.04.2016)
- Hindley-Milner with top-level existentials
- Beyond Church encoding: Boehm-Berarducci isomorphism of algebraic data types and polymorphic lambda-terms
- A Logic for Parametric Polymorphism
- Quantifiers in type theory
- Typed Routing with Continuations
- 型レベル数値リテラル
- 型を表示する関数
- No value restriction is needed for algebraic effects and handlers
- Indexed Codata Types
- Church’s Thesis and Functional Programming
- sheyll/pretty-types
- This post shows how to use the Liar paradox to prove that that Haskell is inconsistent without using recursive terms.
- たのしい型レベルプログラミング
- Quotient Types for Programmers
- Kris Jenkins - Types All The Way Down
- NLambda
- Scrap Your Constructors: Church Encoding Algebraic Types
- Theorem Prover Haskellの紹介
- optparse-declarative のコードリーディングから型レベルプログラミングを学ぶ
- 「タイプセーフプリキュア!」を支える技術
- 問題を解決するつもりでキッチリ型を付けた先にある高い壁
- 構造的部分型と有界量化に関する型推論
- Higher rank polymorphism
- Type Isomorphism
- F-algebras or: How I Learned to Stop Worrying and Love the Type System
- HaskellのRank2Typesがだいぶわかるやつ - Qiita
- TypeApplicationsとAllowAmbiguousTypes - Qiita
- Code Podcast - Episode 5. Type Systems
- Andres Löh - Evolving datatypes - YouTube
- Maciej Bielecki - Programs at the type level - YouTube
- Basic Type Level Programming in Haskell
- Verifying Data Structures in Haskell - Donnacha Oisín Kidney
- Type Level Merge Sort (Haskell)
- Type Tac Toe: Advanced Type Safety
- GHCのforallと多相性への対処 - Qiita
- Computing with Impossible Types
- Constructing Dependent Vectors
- [Haskell-cafe] [ANN]: fin & vec
- Dependent Types in Haskell
- Overlapping and Order-Independent Patterns
- しりとりの圏の実装(未完) - Qiita
- あいや☆ぱぶりっしゅぶろぐ! - baseパッケージにある型レベルプログラミング探検の旅
- Kindについて - Qiita
- dbp.io :: How to prove a compiler correct
- Heterogeneous collections
- Type safe records as an excuse to learn type level programming in Haskell - Entropic ramblings by a Random Agent.
- The HKD pattern and type-level SKI
- Type-Level Induction in Haskell - Donnacha Oisín Kidney
- Lysxia - Heterogeneous lists with dependent types in Haskell
- TYPEREP-MAP STEP BY STEP
- named: Named parameters (keyword arguments) for Haskell
- Verified AVL Trees in Haskell and Agda - Donnacha Oisín Kidney
- Typesafe Versioned APIs
- jaspervdj - Dependent Types in Haskell: Binomial Heaps 101
- Parsing type-level strings in Haskell
- RankNTypes と型レベルリストと extensible - Qiita
- Typeable — A long journey to type-safe dynamic type representation
- Experimenting with Kleisli instance of kind-indexed Category (relies on not-yet merged Visible Kind Applications) : haskell
- Cooper Storage and Type-Level Haskell — Alex Drummond
- Typeable and Data in Haskell
- Higher-order type-level programming in Haskell - Microsoft Research
- コンパイル時に素数判定を行ってみた - Qiita
- Lysxia - Higher-rank types in Standard Haskell
- Discovering DataKinds at Runtime - Programmable Computer
- [1905.13706] A Role for Dependent Types in Haskell (Extended version)
- Type-level FizzBuzz feat. UnsaturatedTypeFamilies
- On the arity of type families - Ryan Scott
- Faking Fundeps with Typechecker Plugins :: Reasonably Polymorphic
- chshersh/type-errors-pretty: Combinators for writing pretty type errors easily
- The surprising rigidness of higher-rank kinds - Ryan Scott
- functor.tokyo – Open Sum Types in Haskell with world-peace
- A story told by Type Errors
- isovector/type-errors: tools for writing better type errors
- 8つの質問で、GHC の type-level language 業界の現状を知る - konn-san.com
- Juvix: dependent-linearly-typed core language with optimal reduction and interaction nets : haskell
- Applying Type-Level and Generic Programming in Haskell
- Haskell’s kind system - a primer · dcastro
- Five benefits to using StandaloneKindSignatures - Ryan Scott
- Let’s Get Dangerous
- Type Witnesses in Haskell
- Sci-Hub | Review of “Thinking with Types”* by Sandy Maguire, LeanPub, 2019. Journal of Functional Programming, 30 | 10.1017/S0956796820000015
-
[Notes for ‘Thinking with Types: Type-level Programming in Haskell’, Chapters 1–5 abhinavsarkar.net](https://abhinavsarkar.net/posts/twt-notes-1/) - A Type-Safe Approach to Categorized Data | Eli Peery
- GHCの型レベル自然数を理解する - Qiita
- A quick-and-dirty check that a type-level string starts with a certain prefix
- リテラルにTypeApplicationsを使えない理由とその対策、あるいはTypeApplicationsの注意点 - Qiita
- A Quick Look at Impredicativity (Simon Peyton Jones) - YouTube
- HaskellでUnion typeを実現するopen-unionを使ってみました - Qiita
- QuasiQuoteでopen-unionを書きやすくするライブラリを作ってみました - Qiita
- Automatically detecting and instantiating polymorphism
- Simpler and safer API design using GADTs
- Haskell’s @ symbol - Type Application | Zac Wood
- Why kind-level foralls don’t interact with ScopedTypeVariables - Ryan Scott
- An introduction to typeclass metaprogramming
- Type Families in Haskell: The Definitive Guide
- Haskell for all: How to replace Proxy with AllowAmbiguousTypes
- Design for Dependent Types - ghc-proposals
- Using dependent types to write proofs in Haskell | Ascetic Slug
- Associated Types In Two Different Ways - MorrowM
- Do disturb me | Typed Programs Don’t Leak Data
- [1708.09158] Type Safe Redis Queries: A Case Study of Type-Level Programming in Haskell
- [1706.09715] Constrained Type Families
- haskell-handbook/forall.md at master · wasp-lang/haskell-handbook
- Oleg’s gists - Leibniz coercion
- Leibniz equality in Haskell, part 2: heterogeneous equality - Ryan Scott
- Haskell’s Type System Standing Alone
- Type-level sharing in Haskell, now - Well-Typed: The Haskell Consultants
data Bottom
data (:==:) :: k -> k -> * where
Refl :: a :==: a
type Not p = p -> Bottom
type a :/=: b = Not (a :==: b)
出典: ロジックパズルの解説
data HList (as :: [*]) where
HNil :: HList '[]
HCons :: a -> HList xs -> HList (a ': xs)
出典: DataKinds 言語拡張を使って Typed Heterogeneous List とその基本操作を実装してみた
Constraint
- The constraints package
- Constraint Kinds for GHC
- The Constraint kind
- The constraint trick for instances
- mikeizbicki/ifcxt
- Monads Made Difficult
- Infinite Negative Utility: Haskell Type Equality Constraints
- Opaque constraint synonyms – ( )
Phantom Type
- Phantom Types and Subtyping
- 型安全なリストを作るのです(`・ω・´) ~ その1、Phantom Type(幽霊型)入門ですー>ω<
- Phantoms
- What is the purpose of
Data.Proxy
? - Data.Functor.Constant
- Data.Tagged
- 【幽霊型トリック集】キェェ!幽霊型でバグを呪い殺すのじゃ!【呪術プログラミング】
- Kwang’s Haskell Blog - Data.Proxy
- で、出たー!幽霊型だー!(Phantom Type) - Qiita
- Oleg’s gists - Flag, a tagged Bool
- 「混ぜられない数」をHaskell/GHCの型を使って手軽につくる - Qiita
- articles/tag-dont-type.md at master · quchen/articles
- Tagged is not a Newtype | Freckle Education
- Phantom Types and Globbing Bugs | pbrisbin dot com
data Circle
data Rectangle
data Shape t where
Circle :: Float -> Float -> Float -> Shape Circle
Rectangle :: Float -> Float -> Float -> Float -> Shape Rectangle
surface :: Shape t -> Float
surface (Circle _ _ r) = …
surface (Rectangle x1 y1 x2 y2) = …
circum :: Shape Circle -> Float
circum (Circle _ _ r) = …
https://www.reddit.com/r/haskell/comments/2jsz4t/function_on_a_single_member_of_a_sum_type/clevra9
存在型
forall
s in Data Types – Brandon Chinn- Haskell/存在量化された型
- Existentials and the heterogenous list fallacy
- Existential Quantification Patterns and Antipatterns
- Proxies and Delegation vs. Existential Types
- Existential quantification
Reflection
- The reflection package
- Lost in Technopolis - A case of reflection
- Tweag I/O - All about reflection:
a tutorial - Data.Reflection
- Typed reflection in Haskell
- Refinement Reflection on ADTs: Lists Are Monoids
- Haskell (GHC) の型レベル自然数とリフレクションを試してみる
- Reflecting values to types and back
- 型を実行時に作る:怖くないリフレクション - Qiita
- Mirror Mirror: Reflection and Encoding Via
Type Inference
- Introduction to Type Inference
- 第 16 章 Hindley/Milner 型推論
- An Explanation of Type Inference for ML/Haskell
- Haskell Suite: Type inference.
- Type Systems as Macros
- Generic unification
- Infernal Types
- [1711.04718] A Type Checking Algorithm for Higher-rank, Impredicative and Second-order Types
- Haskellの型システムを書く(1) - 純粋技術メモ
- 型システムを学ぼう!
- A reckless introduction to Hindley-Milner type inference
- Tripping up type inference – ( )
- [Haskell] asTypeOf の使い方と仕組み
- [1911.06153] Kind Inference for Datatypes: Technical Supplement
Parametricity
- Theorems for free!
- Parametricity
- Parametricity Tutorial (Part 1)
- Parametricity Tutorial (Part 2): Type constructors and type classes
- Automatic generation of free theorems
- Are Functor instances unique?
- Notes on Parametricity
- Parametricity in an Impredicative Sort
- Parametricity: Money for Nothing and Theorems for Free
- The Essential Tools of Open-Source: Functional Programming, Parametricity, Types
- Parametricity and excluded middle
- Djinn
- Typing Haskell in Haskell
- Typing Haskell in Haskellを読んでみる - Qiita
- Stitch: The Sound Type-Indexed Type Checker
定理証明
- 定理証明リンク集 - The curse of λ
- しりとりの圏の回答、または定理証明Haskellを少しだけ - Qiita
- 定理証明系 Haskell
- 依存型による定理証明Tips: coherenceは型で表せ
- Verifying Effectful Haskell Programs in Coq
- Ghosts of Departed Proofs Convenience
- Certified Programming with Dependent Types
- Announcing Spectacle-A language for Writing & Checking Formal Specifications in Haskell
Dependent Types
- Why Dependent Haskell is the Future of Software Development - Serokell
- 実世界を扱う依存型プログラミングのたぶん基本~外界から安全な世界までの道
- Dependent Types
- Fixed-Length Vector Types in Haskell, 2015
- Fixed-Length Vector Types in Haskell (an Update for 2017) · in Code
- Smarter conditionals with dependent types: a quick case study
- Hasochism
- Approximate Dependent-Type Programming
- Chris Casinghino - Making Dependent Types Practical
- System FC with Explicit Kind Equality
- Planned change to GHC: merging types and kinds
- Type is not in Type
- Dependently typed programming and theorem proving in Haskell
- System FC with Explicit Kind Equality
- Part I: Dependent Types in Haskell
- Stephanie Weirich on Dependent Typing, Extending Haskell, Type System Research
- First Experiments With Dependent Types In GHC
- 11 Levity Polymorphism In Dependent Haskell
- A Specification for Dependently-Typed Haskell (Extended version)
- A type theory based on indexed equality - Implementation
- Dependent types in Haskell: Progress Report | Types and Kinds
- Induction is Not Derivable in Second Order Dependent Type Theory
- The Influence of Dependent Types – Stephanie Weirich - YouTube
- Dependent Types in Haskell: Theory and Practice
- A specification for dependent types in Haskell
- Transforming data structures into types: an introduction to dependent typing and its benefits
- Overlapping and Order-Independent Patterns - Definitional Equality for All
- Dependent Types in Haskell
- 依存型の紹介と応用としてのClashの紹介 - Qiita
- Variable-arity zipWith in terms of Applicative ZipList
- liftAN - Donnacha Oisín Kidney
- Visible dependent quantification in Haskell - Ryan Scott
- Dependently typed Haskell in industry (experience report)
- [1610.07978] Dependent Types in Haskell: Theory and Practice
- [1905.13706] A Role for Dependent Types in Haskell (Extended version)
- Dependent Types are a Runtime Maybe
- Leibniz equality in Haskell, part 1 - Ryan Scott
- How Dependent Haskell Can Improve Industry Projects
- Rebecca Skinner - An Introduction to Type Level Programming
Why use a dependent pair? A part from more advanced uses such as proof construction, online tutorials cite dependent typing as a way to make programs more correct (e.g., avoiding access to zero sized vector). Others say that dependent types allow to describe more precisely the intended behavior of programs. The way I see it is that they can reduce the combinatorial space of cases to consider when building a function.
Vittorio Zaccaria - Home page
{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeFamilies #-}
data N = Z | S N -- natural numbers
data Vec a (n :: N) where
Nil :: Vec a Z
Cons :: a -> Vec a n -> Vec a (S n)
vecTail :: Vec a (S n) -> Vec a n
vecTail (Cons _ tl) = tl
data IsNull (n :: N) where
Null :: IsNull Z
NotNull :: IsNull (S n)
vecNull' :: Vec a n -> IsNull n
vecNull' Nil = Null
vecNull' (Cons _ _) = NotNull
type family Pred (n :: N) :: N where
Pred Z = Z
Pred (S n) = n
shorten :: Vec a n -> Vec a (Pred n)
shorten xs = case vecNull' xs of
Null -> xs
NotNull -> vecTail xs
出展: Smarter conditionals with dependent types: a quick case study
一般化代数的データ型
- 一般化代数データ型(GADT)
- GADTs使ってみた
- 型安全なリストを作るのです(`・ω・´) ~ その2、GADTsと依存型>ω<
- GADTs - Haskell for all
- Haskell/GADT
- GADTs
- Question: Type System and N-Dimensional Vectors
- GADTs and exhaustiveness: looking for the impossible
- GADTsとかPhantom typesとかExistential typesとか
- DataKindsとGADTの使い方について
- Ghostbuster: A Tool for Simplifying and Converting GADTs
- Problems with GADT and deriving
- Tying Shoes with GADTs - MorrowM
Multi-parameter type class
Lucid の例
class Term arg result | result -> arg where
termWith :: Text -> [Attribute] -> arg -> result
-- https://hackage.haskell.org/package/lucid/docs/Lucid-Base.html#t:Term
p_ :: Term arg result => arg -> result
-- https://hackage.haskell.org/package/lucid/docs/Lucid-Html5.html#v:p_
Functional dependencies
- Functional dependencies
- 24 Days of GHC Extensions: Functional Dependencies
- Typed type-level programming in Haskell, part I: functional dependencies
Type Families
- GHC/Type families - HaskellWiki
- What are type families?
- 24 Days of GHC Extensions: Type Families
- Fun with type functions
- Typed type-level programming in Haskell, part II: type families
- 2 Minute intro to Associated Types / Type Families
- Type family
- Kind
- http://ja.stackoverflow.com/a/10475
- 普通のtype classesとmulti-parameter type classesとfunctional dependenciesとtype families
- Inductive family of types
- Injective type families
- Injective type families for Haskell
- Type Families with Class, Type Classes with Family
- Type Families and Pokemon.
- Kwang’s Haskell Blog - Type-level functions using closed type families
- HaskellのType Families
- mazzo.li – blag – Configurable data types
- タプルで作ったリストの要素を型で取り出す - 閉じた型シノニム族の使用例 - Qiita
- 決定性有限オートマトンを実装する - データ族の使用例 - Qiita
- Bloggy Badger: Computing with Impossible Types
- TypeFamilyDependencies の実用的な例を考える - ryota-ka’s blog
- Lysxia - Haskell with only one type family
- Functional Dependencies & Type Families • gvolpe’s blog
- Associated Types and Haskell
- Forbidden Haskell Types | Semantic Dreams
- Unordered Function Application In Haskell
- Mitchell Vitez
-- https://www.youtube.com/watch?v=snOBI8PcbMQ
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Proxy
class Eval x where
eval :: Proxy x -> Int
data One
data Add a b
instance Eval One where
eval _ = 1
instance (Eval a, Eval b) => Eval (Add a b) where
eval _ = eval (Proxy :: Proxy a)
+ eval (Proxy :: Proxy b)
-----------------------------------------
data Hole
class Eval' a where
type Value a r :: *
eval' :: Proxy a -> (Int -> r) -> Value a r
instance Eval' One where
type Value One r = r
eval' _ ret = ret 1
instance (Eval' a, Eval' b) => Eval' (Add a b) where
type Value (Add a b) r = Value a (Value b r)
eval' _ ret = eval' (Proxy :: Proxy a) (\v1 ->
eval' (Proxy :: Proxy b) (\v2 ->
ret (v1 + v2)))
instance Eval' Hole where
type Value Hole r = Int -> r
eval' _ ret n = ret n
Singleton
- singletons
- Singletons
- Introduction to Singletons (Part 1) · in Code
- Introduction to Singletons (Part 2) · in Code
- Introduction to Singletons (Part 3) · in Code
- Introduction to Singletons (Part 4) · in Code
- How GHC 8.8 nearly killed singletons - Ryan Scott