普段Scalaを使っていて、この機能は便利、よくできていると感じているところをご紹介します。
This file contains 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 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 |
This file contains 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
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 |
This file contains 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
module Persimmon.Types | |
type StoppedCause = | |
| Skipped of string | |
| Violated of string | |
| Error of exn | |
type AssertionResult<'T> = | |
| Passed of 'T | |
| Stopped of NonEmptyList<StoppedCause> |
This file contains 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 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 |
This file contains 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 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 |
This file contains 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
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. |
This file contains 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
class _Main { | |
static function id.<T>(x: T): T { return x; } | |
static function main(args: string[]): void { | |
log (_Main.id("hello")); | |
} | |
} |
This file contains 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 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 |
This file contains 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
<#@ 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" #> |