Skip to content

Instantly share code, notes, and snippets.

View bleis-tift's full-sized avatar

bleis-tift bleis-tift

View GitHub Profile
type FloatEq = FloatEq of float * float
let (=.) a b = FloatEq (a, b)
let (<+->) (FloatEq (a, b)) e = abs (a - b) < e
10.3 =. 9.9 <+-> 0.5 // => true
10.3 =. 9.9 <+-> 0.1 // => false
module main
open System
open FsXaml
type App = XAML<"App.xaml">
[<STAThread>]
[<EntryPoint>]
let main argv =
元のコード 変更後のコード ソース互換性 バイナリ互換性 メモ
let f x y = ... let f (x, y) = ... No
let f (x, y) = ... let f x y = ... No
type t = int type s = int No Yes 型略称の名前を変更してもF#用のメタデータにしか影響はない
[<CN("a")>] type t = ... [<CN("a")>] type s = ... No Yes IL上の言語からはCNが変わっていなければいい

略語一覧

  • CNCompiledName
@bleis-tift
bleis-tift / sample.adoc
Last active April 22, 2016 01:49 — forked from xmeta/sample.adoc

タイトル

第一章

350x150
図1.1: hogehoge
@bleis-tift
bleis-tift / assertSeqEquals.fs
Created April 8, 2016 02:35 — forked from Gab-km/assertSeqEquals.fs
Persimmon の暫定的な assertSeqEquals を書いてみた
(*
* The MIT License (MIT)
*
* Copyright (c) 2016 Kazuhiro Matsushima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
open System
type Sound = Z | D | K
with
override this.ToString() =
match this with
| Z -> "ズン"
| D -> "ドコ"
| K -> "キ・ヨ・シ!"
1. Expect: [{Row = 0;
Column = 0;
MergedRows = 1;
MergedColumns = 1;
Format =
{RepresentationFormat =
OneReprFormat {Color = null;
Condition = null;
Format = NumericFormat [NFCLiteral "General"];};
Layout = {HorizontalLayout = HLStandard;
@bleis-tift
bleis-tift / StateMonad.cs
Created December 10, 2015 05:34
型だけ合わせてみたC#でStateモナド
using System;
namespace StateMonad
{
// sample:
// var proc =
// from initVal in State.Get<int>()
// let x = initVal + 10
// from _ in State.Put(x * 2)
// select (x / 2).ToString();
@bleis-tift
bleis-tift / Program.cs
Last active October 19, 2015 08:41
ldc.i4.sで負数をintのままemitすると不正なILが生成される
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.Reflection.Emit;
namespace SampleApplication
{
open System
let dic = [ ["今日"; "ぞい"]; ["も"]; ["1"; "ぞい"]; ["日"; "ぞい"]; ["がん"; "ぞい"]; ["ばる"; "ぞい"]; ["ぞい!"]]
let rnd = Random()
let makeZoi (xss: string list list) =
let rec makeZoi' (xss: string list list, count) =
match xss, count with
| xs::xss, count ->
let crnt = xs.[rnd.Next(List.length xs)]
let rest, count = makeZoi' (xss, if crnt.Contains("ぞい") then count + 1 else count)