Skip to content

Instantly share code, notes, and snippets.

View kitasuke's full-sized avatar

Yusuke Kita kitasuke

View GitHub Profile

Comparing the Two Approaches

Pure Inference Rules-Augmented Inference
Time-to-first-output Fast Slow at first
Output variance High — every run produces a different design Low — designs converge to the rules
Team-wide reproducibility & scalability None — best prompter wins; results don't generalize Yes — sharpen the rules, lift everyone's output
Review burden Heavy — review at the design level Light — just check rule conformance
Stability across model switches Fragile — re-tune prompts Stable — rules outlive models

2つのアプローチの比較

純粋な推論 ルール付き推論
初回出力までの速さ 速い 最初は遅い
出力のブレ 大きい ― 毎回違う設計が出る 小さい ― ルールに収束する
チーム全体での再現性・スケーラビリティ なし ― プロンプトの上手な人が勝ち、結果が一般化しない あり ― ルールを磨けば全員のアウトプットが上がる
レビュー負荷 大 ― 設計レベルから見る必要がある 小 ― ルール準拠かを見ればよい
モデル切り替え時の安定性 脆弱 ― プロンプトを再チューニング 安定 ― ルールはモデルを超えて生き残る
@kitasuke
kitasuke / SwiftPM-Function-Builders.swift
Last active September 10, 2019 02:11
Experimental code for SwiftPM with Function Builders. Declarative package description for SwiftPM.
import Foundation
@_functionBuilder
struct ContentListBuilder {
static func buildBlock() -> ContentList {
return EmptyContentList()
}
static func buildBlock(_ list: ContentList) -> ContentList {
@kitasuke
kitasuke / StringLiteralExpr-jp.md
Created August 3, 2019 12:33
StringLiteralExpr-jp

Swift 5.1へのStringLiteralExprの改善

こんにちは。iOSエンジニアの@kitasukeです。

今回は、Swift Compilerのパーサー内部でlibSyntaxが作成する、StringLiteralExprに関する改善を行ったので、その内容を簡単に紹介します。
ちなみに、この変更はlibSyntax内での変更でありSwiftのString APIへの変更ではありません。

概要

libSyntaxには、Stringリテラル用にStringLiteralExprStringInterpolationExprの2種類のシンタックスが定義されています。

@kitasuke
kitasuke / defer.sil
Last active March 1, 2018 14:18
Swift -> SIL
sil_stage canonical
import Builtin
import Swift
import SwiftShims
// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%2 = integer_literal $Builtin.Int32, 0 // user: %3
@kitasuke
kitasuke / defer.sil
Created March 1, 2018 14:03
Swift -> SIL
sil_stage canonical
import Builtin
import Swift
import SwiftShims
// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
%2 = integer_literal $Builtin.Int32, 0 // user: %3
import Foundation
import RxSwift
import FBSDKCoreKit
import FBSDKLoginKit
enum FacebookSDKError: Error {
case tokenNotFound
}
extension Reactive where Base: FBSDKLoginManager {
import UIKit
import RxSwift
import RxCocoa
extension Reactive where Base: UITableView {
func items<S: Sequence, Cell: UITableViewCell, O: ObservableType>
(cellType: Cell.Type)
-> (_ source: O)
-> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void)
-> Disposable

Type-safe API call with Protocol Buffers in Swift

Apple recently open sourced swift-protobuf which is a plugin of Protocol Buffers for swift language. Protocol Buffers in Swift enables us to have type safety, make API faster and unify schema documentation of structured data. I had a chance to use swift-protobuf in my project and thought that there are many benefits for us, so I would like to share my thoughts.

I also created a repository which has sample server/client app with Protocol Buffers. Please take a look here if you're interested in what implementation looks like.

What's Protocol Buffers?

import Foundation
import APIKit
protocol ProtobufRequest: Request {}
extension ProtobufRequest {
var dataParser: DataParser {
return ProtobufDataParser()
}
}