Skip to content

Instantly share code, notes, and snippets.

@zecl
zecl / Sample.fs
Last active September 8, 2015 15:44
module Sample
let counter =
let makeCounter () =
let i = ref 0
fun () ->
i := !i + 1
!i
makeCounter ()
@zecl
zecl / Program.fs
Created August 1, 2014 05:37
MonoGame(F#) でウィンドウに好きなアイコンを設定する方法
namespace Sample
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
type SampleGame () as this =
inherit Game()
let gametitle, gmanager, sprite = "Sample", new GraphicsDeviceManager(this), lazy new SpriteBatch(this.GraphicsDevice)
do
gmanager.PreferredBackBufferWidth <- 800
@zecl
zecl / Script.fsx
Last active August 29, 2015 14:03
F# Compiler Serviceでソースコードからすべての型のFullNameを取得
// F# Compiler Service
#r @"..\packages\FSharp.Compiler.Service.0.0.57\lib\net45\FSharp.Compiler.Service.dll"
open System
open Microsoft.FSharp.Compiler.SourceCodeServices
open Microsoft.FSharp.Compiler.Ast
let checker = InteractiveChecker.Create()
let getUntypedTree (file, input) =
let checkOptions = checker.GetProjectOptionsFromScript(file, input, otherFlags = [| "--define:DEBUG" |]) |> Async.RunSynchronously
SyntaxHighlighter.brushes.FSharp = function() {
var keywords =
'abstract and as assert base begin class default delegate do done ' +
'downcast downto elif else end exception extern false finally for ' +
'fun function if in inherit inline interface internal lazy let ' +
'match member module mutable namespace new null of open or ' +
'override private public rec return sig static struct then to ' +
'true try type upcast use val void when while with yield ' +
'asr land lor lsl lsr lxor mod ';
@zecl
zecl / Program.fsx
Created March 31, 2013 13:03
FsControl (https://github.com/gmpl/FsControl) を拡張してお遊び
#r @"bin\Debug\FsControl.Core.dll" // from https://github.com/gmpl/FsControl
module Monad =
open FsControl.Core.Abstractions
let do' = new Monad.DoNotationBuilder()
module MonadPlus =
open Monad
open FsControl.Core.Abstractions.MonadPlus