Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
nakamura-to / Program.fs
Last active July 27, 2017 12:29
F# Computation Expression for ADO.NET TRANsactional Queries
open System.Data.SqlClient
open Tranq
open Tranq.Directive
let insert = required {
let! _ = Database.execute "insert person (id, name) values (1, 'hoge1')"
let! _ = Database.execute "insert person (id, name) values (2, 'hoge2')"
let! _ = Database.execute "insert person (id, name) values (3, 'hoge3')"
return () }
@hisui
hisui / stream.ts
Last active August 21, 2020 21:20
Functional Reactive Programming (FRP) in TypeScript.
// stream.ts - A TypeScript module for FRP.
// - https://gist.github.com/hisui/6261547
// - tsc stream.ts -t es5 --sourcemap --noImplicitAny
module sf {
export class Packet<T> {
constructor(private _flags:number, private _value:any=void 0) {}
static next<A>(e:A):Packet<A> {
@geoder101
geoder101 / TaskLinqExtensions.cs
Last active February 6, 2018 06:46
TPL C# extension methods
namespace Extensions
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
/// <summary>
/// LINQ extension methods for the TPL-'Task' monad.
/// </summary>
/// <remarks>
@swlaschin
swlaschin / FsCsInterop.md
Last active July 9, 2024 15:41
F# to C# interop tips

Tips on exposing F# to C#

Api and Methods

I suggest that you create one or more Api.fs files to expose F# code in a C# friendly way.

In this file:

  • Define functions with PascalCase names. They will appear to C# as static methods.
  • Functions should use tuple-style declarations (like C#) rather than F#-style params with spaces.