[| x |] = λk.k x ・・・val
[| λx.t |] = λk.k (λx.[|t|]) ・・・lam
[| π t |] = λk.[|t|] (λa.k (π a)) ・・・app1
[| t1 t2 |] = λk.[|t1|] (λf.[|t2|] (λa.f a k)) ・・・app2
[| π t1 t2 |] = λk.[|t1|] (λa.[|t2|] (λb.k (π a b)))・・・app3
[| Sx.t |] = λk.[x↦λa.λk'.k' (k a)]([|t|] (λv.v))・・・shift
[| <t> |] = λk.k ([|t|] (λv.v)) ・・・reset
[|<concat (Sk.λx.k x) (Sk.λx.k (i2s x))> "a" 10|]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[|(λv.λv2.v2) ((λv.v v) (λv.v v))|] | |
1. app2 -> λk1.[|λv.λv2.v2|] (λf1.[|(λv.v v) (λv.v v)|] (λa1.f1 a1 k1)) | |
2. lam -> λk1.(λk2.k2 (λv.[|λv2.v2|])) (λf1.[|(λv.v v) (λv.v v)|] (λa1.f1 a1 k1)) | |
3. lam -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.[|v2|])))) (λf1.[|(λv.v v) (λv.v v)|] (λa1.f1 a1 k1)) | |
4. val -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.(λk4.k4 v2))))) (λf1.[|(λv.v v) (λv.v v)|] (λa1.f1 a1 k1)) | |
5. app2 -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.(λk4.k4 v2))))) (λf1.(λk5.[|λv.v v|] (λf5.[|λv.v v|] (λa5.f5 a5 k5))) (λa1.f1 a1 k1)) | |
6. lam -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.(λk4.k4 v2))))) (λf1.(λk5.(λk6.k6 (λv.[|v v|])) (λf5.[|λv.v v|] (λa5.f5 a5 k5))) (λa1.f1 a1 k1)) | |
7. app2 -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.(λk4.k4 v2))))) (λf1.(λk5.(λk6.k6 (λv.(λk7.[|v|] (λf7.[|v|] (λa7.f7 a7 k7))))) (λf5.[|λv.v v|] (λa5.f5 a5 k5))) (λa1.f1 a1 k1)) | |
8. val -> λk1.(λk2.k2 (λv.(λk3.k3 (λv2.(λk4.k4 v2))))) (λf1.(λk5.(λk6.k6 (λv.(λk7.(λk8.k8 v) (λf7.[|v|] (λa7.f7 a7 k7))))) (λf5.[|λv.v v|] (λa5.f5 a5 k5))) (λa1.f1 a1 k1)) | |
9. val -> λk1.(λk2.k2 (λv.(λk3.k3 ( |
[| x |] = λk.k x ・・・val
[| λx.t |] = λk.k (λx.[|t|]) ・・・lam
[| π t |] = λk.[|t|] (λa.k (π a)) ・・・app1
[| t1 t2 |] = λk.[|t1|] (λf.[|t2|] (λa.f a k)) ・・・app2
[| Sx.t |] = λk.[x↦λa.λk'.k' (k a)]([|t|] (λv.v))・・・shift
[| <t> |] = λk.k ([|t|] (λv.v)) ・・・reset
変換対象: <add10 (Sx.x (x 100))>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CommandInfo = | |
{ Names: string[] | |
Summary: string | |
Syntax: string | |
Help: string option } | |
type CommandWrapper(info: CommandInfo, proc: string -> unit) = | |
inherit Command() | |
override __.Names = info.Names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// シャドーイングの例 | |
// これは無限ループ | |
let x = 0 | |
while x < 10 do // ここでのxは常に最初のx | |
let x = x + 1 // 新しいxのスコープはwhileの本体のみで有効 | |
printfn "%d" x | |
//// 再代入の例 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Collections.Generic | |
type CollectionBuilder< 'TCollection, 'TElem, 'TRet when 'TCollection : (member Add : 'TElem -> 'TRet)> () = | |
[<DefaultValue>] val mutable xs : 'TCollection | |
member inline this.Yield(x: 'TElem) = | |
(^TCollection : (member Add : 'TElem -> 'TRet) (this.xs, x)) |> ignore | |
member inline this.Delay(f) = f | |
member inline this.Combine(_, rest) = rest () | |
member inline this.Run(f) = f (); this.xs | |
member inline this.Zero() = () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================================================ | |
// 共通 | |
//================================================================================ | |
type EmailAddress = | |
{ EAValue: string } | |
type SurfaceAddress = | |
{ SAValue: string } | |
type Customer = |
In the language specification, the translation rule of do! e;
is defined as follows:
T(do! e;, V, C, q) = T(let! () = src(e) in b.Return(), V, C, q)
And the signature of Return
is usually 'a -> M<'a>
, so the type of do! e;
results M<unit>
.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AsyncTaskMethodBuilderのStartが呼び出される | |
stateMachine(生成されるクラス)のMoveNextが呼び出される | |
非同期メソッドの呼び出し結果に対してGetAwaiterが呼び出される | |
AsyncTaskMethodBuilderのAwaitUnsafeOnCompletedが呼び出される | |
AwaitUnsafeOnCompletedが呼び出される | |
GetCompletionActionが呼び出される | |
AsyncMethodBuilder.MoveNextRunnerが生成される(ここにstateMachineのインスタンスが渡される) | |
AsyncMethodBuilder.MoveNextRunnerのRunが返される(中でstateMachineのMoveNextを呼び出している) | |
awaiterのUnsafeOnCompletedが返されたactionを渡して呼び出される | |
ここからはAwaiter次第だが、TaskAwaiterを例にする |
NewerOlder