http://code.google.com/p/fsharp-typeclasses/ てきな型クラスを使おうとすると、コンパイラがNullReferenceExceptionを吐いて落ちることがある。 VS2010でもVS11betaでも再現する。
- 2つのライブラリプロジェクト(TypeClassLibとClientとする)を用意する
module Patterns | |
open Microsoft.FSharp.Reflection | |
let (|PrimitiveType|ListType|RecordType|) t = | |
if t = typeof<int> || t = typeof<string> then | |
PrimitiveType | |
else if FSharpType.IsRecord t then | |
RecordType t | |
else if t.GetGenericTypeDefinition() = typedefof<list<_>> then |
#!/bin/sh | |
msg=${1:-"first commit"} | |
git init | |
tree_hash=$(git write-tree) | |
commit_hash=$(echo -n "$msg" | git commit-tree $tree_hash) | |
echo $commit_hash > .git/refs/heads/master |
using NUnit.Framework; | |
[TestFixture] | |
public class Sample : TestUtil | |
{ | |
[TestCaseSource("TestCases")] | |
public void Test(int i, string expected) | |
{ | |
Assert.That(i.ToString(), Is.EqualTo(expected)); | |
} |
sig System { | |
slist: some SSeat, | |
alist: some ASeat, | |
reserved: set slist + alist | |
} | |
abstract sig Seat {} | |
sig ASeat extends Seat {} | |
sig SSeat extends Seat {} | |
enum SeatType { A, S } |
_require "basis.smi" |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<profile project="MinGW" application="mingw-get"> | |
<repository uri="http://www.pllab.riec.tohoku.ac.jp/smlsharp/download/mingw32/%F.xml.lzma"> | |
<package-list catalogue="smlsharp-package-list" /> | |
</repository> | |
<!-- | |
$Id: profile.xml,v 1.4 2010/08/24 20:02:10 keithmarshall Exp $ | |
Written by Keith Marshall <[email protected]> | |
Copyright (C) 2009, 2010, MinGW Project |
val f = _import "localtime": int array -> time;の場合 | |
(interactive):31.51-31.54 Error: | |
(type inference 003) not an interoperable type: {day: int, | |
dst: int, | |
hour: int, | |
min: int, | |
mon: int, | |
sec: int, | |
wday: int, |
datatype 'a result = | |
Pass | |
| Failure of { Actual: 'a, Expected: 'a } | |
; | |
fun test [] = [] | |
| test (x::xs) = | |
let | |
val actual = (#Target x)() | |
val expected = #Expected x |
http://code.google.com/p/fsharp-typeclasses/ てきな型クラスを使おうとすると、コンパイラがNullReferenceExceptionを吐いて落ちることがある。 VS2010でもVS11betaでも再現する。
// F# | |
type Hoge = A of int | B of int | C of int | |
let (|AllHoge|) (A x | B x | C x) = AllHoge x | |
let f (AllHoge x) = x * 10 | |
let xs = [A 1; B 2; C 3] |> List.map f |