- 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
namespace BlazorApp1.Pages | |
open System | |
open System.Collections.Generic | |
open System.Linq | |
open System.Threading.Tasks | |
open System.Net.Http | |
open Microsoft.AspNetCore.Blazor | |
open Microsoft.AspNetCore.Blazor.Components | |
open Microsoft.AspNetCore.Blazor.Layouts |
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
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b> | |
type F<'a> = QIL<'a> | |
and S<'a> = F<Q<'a>> | |
and Q<'a> = | |
private | |
| Step of Step<'a> | |
| Bind of IBind<'a> | |
with | |
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k)) |
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
> 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
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 |