- Define related sets or sequences of algorithms to be defined together (need explicit example)
- Specify required static extension methods for implementing things like LINQ or Rx.
- Transducers cannot currently be implemented efficiently in .NET.
Transducers would need to use
IEnumerable<_>
as a base collection type rather than potentially more efficient implementations (or retaining the input's stype, e.g.List<_>
, etc). - F# modules such as
List
,Array
, andSeq
all provide functions that are the same in nature but differ by wrapper type.
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 Op = | |
| Add | |
| Multiply | |
static member TryParse input = | |
match input with | |
| "add" -> Some Add | |
| "multiply" -> Some Multiply | |
| _ -> None | |
type Command<'a> = |
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 System | |
type FSharp.Control.AsyncBuilder with | |
[<CustomOperation("and!", IsLikeZip=true)>] | |
member __.Merge(x, y, f) = | |
async { | |
let! token = Async.CancellationToken | |
let! x' = Async.StartChildAsTask x | |
let! y' = Async.StartChildAsTask y | |
do System.Threading.Tasks.Task.WaitAll([|x';y'|], cancellationToken = token) |
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
#load "load-references-debug.fsx" | |
open System.Data.SqlClient | |
open FSharp.Data | |
[<Literal>] | |
let MasterCS = "Server=.;Database=master;Integrated Security=true;" | |
let createDB () = | |
use cmd = new SqlCommandProvider<"create database Test", MasterCS>(MasterCS) | |
cmd.Execute() |> 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 for fizzbuzz results | |
type FizzBuzzResult = | |
| FizzBuzz | |
| Fizz | |
| Buzz | |
| Number of int | |
let fizzbuzz n = | |
match n % 3, n % 5 with | |
| 0, 0 -> FizzBuzz |
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
using System; | |
using System.Linq.Expressions; | |
namespace Foundation.Specifications | |
{ | |
/// <summary> | |
/// Defines an abstract class from which to create conditional specifications. | |
/// </summary> | |
/// <typeparam name="T">The type of entity used in the specification.</typeparam> | |
/// <seealso href="http://ubik.com.au/article/named/implementing_the_specification_pattern_with_linq" /> |
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
> defineGenericDelegate [| typeof<Collections.Generic.IDictionary<string, obj>>; typeof<Threading.Tasks.Task> |];; | |
val it : Type = | |
System.Func`2[System.Collections.Generic.IDictionary`2[System.String,System.Object],System.Thread | |
ing.Tasks.Task] |
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
using System; | |
using System.Linq; | |
using System.Reactive.Linq; | |
using System.Windows.Forms; | |
using DictionarySuggest.DictionarySuggestService; | |
using System.Reactive; | |
namespace DictionarySuggest | |
{ | |
class Program |
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
namespace WebSocket | |
// Appache 2.0 license | |
// References: | |
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455 | |
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/ | |
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py | |
// [4] WebSockets Organising body http://www.websocket.org/echo.html | |
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664 |
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 Newtonsoft.Json | |
let serializerSettings = JsonSerializerSettings(ContractResolver = Serialization.CamelCasePropertyNamesContractResolver()) | |
serializerSettings.Converters.Add(OptionConverter()) | |
let serialize data = | |
JsonConvert.SerializeObject(data, serializerSettings) | |
|> Text.Encoding.UTF8.GetBytes | |
let deserialize<'T> (stream: Stream) = |