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
#if INTERACTIVE | |
#else | |
namespace Examples | |
#endif | |
(* | |
[<Sealed>] | |
type Future<'T> | |
module Future = |
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
module M = | |
[<PrivateRecordConstructor>] // how about F# had something like this? | |
type Config = | |
{ | |
A: string | |
B: string | |
// ... | |
} | |
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
(* | |
Towards verifying message-passing protocols. | |
Protocol typically involves two parties, let us call Client and Server, | |
a number of states and state transitions involving passing of messages. | |
Client has agency - non-deterministic process in process calculi. | |
Server is deterministic, but it should handle all possible clients. | |
Ideally, we would take a DSL for the protocol, and spit out F# code that |
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
module Main | |
open Infers | |
open Infers.Rep | |
type SimpleRecord = { Name: string; Age: int } | |
type LotsOfRecords = { People: SimpleRecord [] } | |
type Cloneable<'T> = | |
| C of ('T -> 'T) |
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
(* | |
# Setup.fsx | |
Adds registry keys for proper F# Web project support. | |
**Problem**: pure-F# Web projects do not work well in Visual Studio by default, | |
in particular adding a new item to the project is not possible. | |
**Solution**: This will hopefully be addressed in future VS versions. |
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
module Monad = | |
type M<'T,'B when 'B :> Sig<'B>> = | |
interface end | |
and Sig<'B when 'B :> Sig<'B>> = | |
abstract member Return<'X> : 'X -> M<'X,'B> | |
abstract member Bind<'X,'Y> : | |
M<'X,'B> -> ('X -> M<'Y,'B>) -> M<'Y,'B> |
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
class functional_point y = | |
object | |
val x = y | |
method get_x = x | |
method move d = {< x = x + d >} | |
end | |
#let p = new functional_point 7;; | |
val p : functional_point = <obj> | |
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
let MapReduce (map: 'T1 -> 'T2) | |
(reduce: 'T2 -> 'T2 -> 'T2) | |
(zero: 'T2) | |
(inputs: seq<'T1>) = | |
let ( >>= ) x f = async.Bind(x, f) | |
Async.FromContinuations <| fun (ok, no, _) -> | |
let n = Seq.length inputs | |
let reducer = | |
MailboxProcessor.Start <| fun inbox -> | |
let rec loop n s = |
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 View<'T1,'T2> = | |
{ | |
Get : 'T1 -> option<'T2> | |
Set : 'T2 -> 'T1 -> 'T1 | |
} | |
static member Find() = | |
let t1 = typeof<'T1> | |
let t2 = typeof<'T2> | |
if R.IsRecord t1 then |
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.Collections.Generic | |
[<Sealed>] | |
type Channel<'T>() = | |
let sync = obj () | |
let readers = Queue<Future<_>>() | |
let writers = Queue<_>() | |
member this.CanRead : bool = | |
lock sync <| fun () -> writers.Count > 0 |
OlderNewer