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:a450ef2ae7f9e51504ba
Created December 12, 2014 07:45
ネストしたコンピュテーション式に対応
type SimpleBuilder () =
member __.Return(x) = x
member __.Bind(x, f) = f x
let simple = SimpleBuilder()
open Microsoft.FSharp.Quotations.Patterns
open System.Collections.Generic
open FSharp.Quotations.Evaluator
module Poker.List
let trySplitAt count list =
let rec loop i acc tail =
if i = count then Some ((List.rev acc), tail)
else match tail with
| [] -> None
| h::t -> loop (i + 1) (h::acc) t
loop 0 [] list
module Persimmon.Types
type StoppedCause =
| Skipped of string
| Violated of string
| Error of exn
type AssertionResult<'T> =
| Passed of 'T
| Stopped of NonEmptyList<StoppedCause>
open FParsec
open FParsec.CharParsers
let toInt ch = (int ch) - (int '0')
let parser = parse {
let! head = digit |>> toInt
do! digit |>> ignore
do! digit |>> ignore
do! digit |>> ignore
type NonEmptyList<'T> = 'T * 'T list
type AssertResult<'T> =
| Failure of NonEmptyList<string>
| Success of 'T
type TestBuilder(description: string) =
// これを解除するとコンパイルエラーになってしまう・・・
// member __.Bind(x, f) =
// match x with

Scala おすすめポイントご紹介


おすすめポイント

普段Scalaを使っていて、この機能は便利、よくできていると感じているところをご紹介します。


準備

@bleis-tift
bleis-tift / gist:9970810
Last active September 14, 2015 12:51
FAKE使いたくない
Hi,
I don't think that we should use FAKE.
FAKE is a good tool, but FAKE has many problems to be used widely.
1. FAKE.exe runs too slowly.
2. FAKE uses AutoOpen too much. It makes difficult to understand the build script.
In the build script, "commit" and "Commit" has entirely a different meaning.
3. FAKE uses AutoOpen too much. Then, we always have to be very carefully to extend FAKE.
4. FAKE script is hard to read, because it does not have a variable expansion. So we have to use sprintf.
class _Main {
static function id.<T>(x: T): T { return x; }
static function main(args: string[]): void {
log (_Main.id("hello"));
}
}
type Color = Red | Black
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module internal Color =
let height = function Red -> 0 | Black -> 1
type Entry = { Key: string; Value: string }
type RBTree =
| Empty
@bleis-tift
bleis-tift / 0.TupleComparer.tt
Last active December 19, 2015 12:19
非ジェネリックなIComparableに明示的にキャストして比較するか、やはり非ジェネリックなIStructuralComparableに明示的にキャストして比較するか・・・ それが嫌な場合、IComparerを作る、ということになるだろうが・・・これ、16要素までT4ったらどんだけのコードが出来上がるんですかね →16要素だと100万行のファイルが出力されて、コンパイルできなかった
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core" #>
<#@ Assembly Name="System.Windows.Forms" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>