Skip to content

Instantly share code, notes, and snippets.

View bleis-tift's full-sized avatar

bleis-tift bleis-tift

View GitHub Profile
@bleis-tift
bleis-tift / gist:2904624
Created June 10, 2012 09:26
JSXใงใ‚ซใƒชใƒผใช็„กๅ้–ขๆ•ฐๆ›ธใ„ใŸใ‚‰ๆญปใญใ‚‹
// ไปŠใฎJSXใ ใจไฝ•ๆ›ธใ„ใฆใ‚‹ใ‹ใ‚ใ‹ใ‚‰ใ‚“
var adder1 = function(x: int): function(: int): int {
return function(y: int): int { return x + y; };
};
// ไฟบใฎๆๆกˆใงใ‚‚->ใงๆญปใฌใ‚‹ใŒใ€
var adder2 = (x: int): (int) -> int -> (y: int): int -> x + y;
// ็„ก็†ใ—ใฆsimple lambdaไฝฟใ‚ใชใ‘ใ‚Œใฐใ€ใใ‚Œใชใ‚Šใซ่ชญใ‚ใ‚‹
var adder3 = (x: int): (int) -> int -> {
return (y: int): int -> x + y;
};
@bleis-tift
bleis-tift / gist:2969500
Created June 22, 2012 00:32 — forked from forki/gist:2964839
Static duck typing (F#2.0)
let inline speak (a: ^a) =
let x = (^a : (member Name: string) (a))
printfn "I'm %s" x
let y = (^a : (member talk: unit -> string) (a))
printfn "I say %s" y
//type Duck =
// { Name : string } // Name is not property in F# 2.0
//
// member x.talk() = "quackity quack"
@bleis-tift
bleis-tift / gist:3774779
Created September 24, 2012 07:36
ๅž‹ๆ‹กๅผตใงใ‚ชใƒผใƒใƒผใƒญใƒผใƒ‰ใ™ใ‚‹ใจๅผๆœจใŒๅ–ใ‚Œใชใ„
// fsiใง
type Hoge() =
member this.Piyo(i: int) = "piyo1"
member this.Piyo(s: string) = "piyo2"
let f () =
<@ (fun (h: Hoge) -> h.Piyo(42)) @>;; // <- ใ“ใ“ใจใ€
type Hoge with
// ใƒญใƒผใ‚ซใƒซๅค‰ๆ•ฐใฎletใฏใ€C#ใฎvarใจๅŒใ˜ใ‚‚ใฎใจๆ€ใฃใฆใŠใ‘ใฐ(ใจใ‚Šใ‚ใˆใšใฏ)ใ‚ˆใ„
// var x = 42;
let x = 42
// ้–ขๆ•ฐๅฎš็พฉใฎletใฏใ€C#ใง
// var f = new Func<int, string>(i => i.ToString());
// ใจใ„ใ†ๆ›ธใๆ–นใงใ€้–ขๆ•ฐๅฎš็พฉใ‚‚ใงใใฆใ—ใพใ†ใ€ใจ่€ƒใˆใ‚‹
let f (i: int) = i.ToString()
@bleis-tift
bleis-tift / gist:3915964
Created October 19, 2012 02:48
ๅ‡ฆ็†็ตๆžœใ‚ณใƒผใƒ‰ใƒžใ‚ธใ‚ฏใ‚ฝ
public class Hoge
{
// ๅ‡ฆ็†็ตๆžœใ‚ณใƒผใƒ‰ใ‚’่ฟ”ใ™
public string Piyo(...) { ... }
public readonly int ResultA;
public readonly string ResultB;
}
var code = h.Piyo(...);
@bleis-tift
bleis-tift / TaskMonad.cs
Created November 20, 2012 07:18 — forked from yoshihiro503/TaskMonad.cs
C# ใง้žๅŒๆœŸใ‚ฟใ‚นใ‚ฏ ใƒขใƒŠใƒ‰ๆ›ธใ„ใฆใฟใŸใ€‚
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Proofcafe
{
public static class TaskMonad
interface A {
hoge(str:string): string;
}
interface B {
hoge(str:string): string;
}
class AImpl implements A {
hoge(str) {
public abstract class Base<T>
{
public abstract T Method();
}
public class Sub1 : Base<int>
{
public override int Method() { return 0; }
}
using System;
namespace LangExt.Playground
{
public sealed class LazyVal<T>
{
T value;
bool hasValue = false;
readonly Func<T> f;
@bleis-tift
bleis-tift / 0.LazyVal.cs
Last active December 17, 2015 07:28 — forked from anonymous/gist:5572563
System.Lazyใฎๅˆๆˆใงใใ‚‹็‰ˆ็š„ใช
using System;
using System.ComponentModel;
namespace LangExt.Playground
{
public sealed class LazyVal<T>
{
readonly Func<T> f;
bool hasValue = false;
T value;