SATySFiの字句解析器には主要なモードが4つある:
- プログラムモード
- 垂直モード
- 水平モード
- 数式モード
またサブモードとして
| use std::rc::Rc; | |
| trait HKT<U> { | |
| type C; // Current type | |
| type T; // Type with C swapped with U | |
| } | |
| macro_rules! derive_hkt { | |
| ($t:ident) => { | |
| impl<T, U> HKT<U> for $t<T> { |
パターンとはその言語が抽象化できなかった敗北の歴史である。 しかしどんなに優れた言語であってもあらゆる繰り返しに勝てるわけではない。 人は必ずメタ繰り返しを欲するからだ。 そしてそれはRustも例外ではない。
ここでは、OOPでも知られているパターンよりも、Rustに特有のパターンを思いつく限りまとめてみた。名前は適当。
| // Copyright (C) 2019 Rui Ueyama | |
| // Licensed under the MIT license | |
| // | |
| // This command parses a C declaration. Here are a few examples: | |
| // | |
| // $ ./cdecl 'int x' | |
| // x: int | |
| // | |
| // $ ./cdecl 'int **const *x' | |
| // x: pointer to const pointer to pointer to int |
| {-# LANGUAGE DataKinds #-} | |
| -- | My database API. | |
| module DBAPI where | |
| import Data.Defaults | |
| data ConnSpec p = ConnSpec | |
| { username :: !(Required p String) |