This file contains hidden or 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.IO | |
open System.Net | |
open System.Text | |
open System | |
let httpAsync (progress : IProgress<string>) (url : string) = async { | |
let req = System.Net.WebRequest.Create(url) | |
use! resp = req.AsyncGetResponse() | |
progress.Report(sprintf "%s AsyncGetResponse" url) | |
use stream = resp.GetResponseStream() |
This file contains hidden or 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 | |
open Microsoft.FSharp.Reflection | |
let readln = Console.ReadLine | |
let writeln = fun a -> | |
let args = if FSharpType.IsTuple(a.GetType()) then FSharpValue.GetTupleFields(a) else [|a|] | |
let fmt = args |> Array.indexed |> Array.fold (fun s e -> s + (sprintf "{%d}" (fst e))) "" | |
Console.WriteLine(fmt.Trim(), args) | |
let write = fun a -> | |
let args = if FSharpType.IsTuple(a.GetType()) then FSharpValue.GetTupleFields(a) else [|a|] |
This file contains hidden or 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
#pragma indent | |
// io.n | |
using System.Console; | |
macro writeln (params a: array[expr]) | |
mutable exps = []; | |
foreach(e in a) | |
exps = <[ Write($e); ]> :: exps; | |
exps = <[ WriteLine();]> :: exps; | |
exps = exps.Reverse(); |
This file contains hidden or 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 Resource () = | |
interface IDisposable with | |
member it.Dispose() = | |
do printfn "Object %A Disposed" it | |
use r = Resource() | |
(r :> IDisposable).Dispose() |
This file contains hidden or 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
public abstract class Result<TValue, TError> | |
{ | |
public bool IsOk => this is Ok; | |
public sealed class Ok : Result<TValue, TError> | |
{ | |
public TValue Value { get; } | |
internal Ok(TValue value) => Value = value; | |
} | |
public sealed class Err : Result<TValue, TError> |
This file contains hidden or 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.Console; | |
using System.Net; | |
using System.Net.Sockets; | |
using System.IO; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
using Nemerle; | |
using Nemerle.Async; |
This file contains hidden or 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.Console; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Nemerle; | |
using Nemerle.Async; | |
enum Tone { | |
| REST = 0 | |
| GbelowC = 196 | |
| A = 220 |
This file contains hidden or 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 now () = System.DateTime.Now.ToString("s") | |
type CacheCommand<'id, 'result> = | |
| Get of 'id * AsyncReplyChannel<Result<'result, string>> | |
| Clear | |
type Cache(getter) = | |
let mailbox = | |
MailboxProcessor.Start(fun inbox -> |
This file contains hidden or 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 TickTocks exposing(..) | |
import Browser | |
import Html exposing (..) | |
import Html.Attributes exposing (style) | |
import Task | |
import Time | |
main = | |
Browser.element | |
{ init = init | |
, view = view |
This file contains hidden or 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
// This sample will guide you through elements of the F# language. | |
// | |
// ******************************************************************************************************* | |
// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter in Windows or | |
// Ctrl-Enter Mac, or right-click and select "Send Selection to F# Interactive". | |
// You can open the F# Interactive Window from the "View" menu. | |
// ******************************************************************************************************* | |
// | |
// For more about F#, see: | |
// http://fsharp.org |
OlderNewer