Skip to content

Instantly share code, notes, and snippets.

View t0yv0's full-sized avatar
🎯
Focusing

Anton Tayanovskyy t0yv0

🎯
Focusing
View GitHub Profile
// Capture: http://docs.phonegap.com/en/2.5.0/cordova_media_capture_capture.md.html
module Capture {
interface ConfigurationData {
type: string;
height: number;
width: number;
}
/// Provides basic types and syntax for defining XML and HTML fragments
/// as a deep EDSL in F#. Design goals:
///
/// A. Allow different concrente interpretations, including:
/// 1. XML documents and fragments
/// 2. HTML(5) documents and fragmetns
/// 3. XML or HTML templates with placeholders and/or instructions
///
/// B. Provide minimal type safetiy ensuring some sanity but not encoding every
/// invariant, which seems not practical with the weak F# type system.
@t0yv0
t0yv0 / subtyping.v
Last active August 27, 2025 17:43
Demonstrating TypeScript 0.8 type system to be unsound. The subtyping relationship is defined in a way that admits the following code that results in TypeError exception being thrown.
Require Import Utf8.
Inductive subtype (a b : Set) : Set :=
| ST : (a -> b) -> subtype a b.
Infix ":>" := subtype (at level 50).
Definition st {x y} f := ST x y f.
Definition unpack {a b : Set} (st : a :> b) :=
open System.IO
type Format<'T> =
{
Read : BinaryReader -> 'T
Write : BinaryWriter -> 'T -> unit
}
(* Unions *)
open System.IO
type Format<'T> =
{
Read : BinaryReader -> 'T
Write : BinaryWriter -> 'T -> unit
}
type FormatUnionPart<'X,'U> =
{
open System
open System.Collections.Generic
open System.Diagnostics
open System.Threading
open System.Threading.Tasks
[<Sealed>]
type Channel<'T>() =
let root = obj ()
let qF = Queue<'T->unit>()
open System
open System.Collections.Generic
open System.Threading
open System.Threading.Tasks
[<Sealed>]
type Channel<'T>() =
let root = obj ()
let qF = Queue<'T->unit>()
let qX = Queue<'T>()
namespace Workers
open System
open System.Collections.Generic
open System.Diagnostics
open System.Linq
open System.Net
open System.ServiceModel
open System.Threading
open System.Threading.Tasks
/// See http://stackoverflow.com/questions/11800168/how-to-implement-the-list-filter-function-in-f-using-primitives
#if INTERACTIVE
#else
module WhatGoesHere
#endif
[<Sealed>]
type Id() = class end
let private isHoliday2011 (dt:DateTime) =
match dt.DayOfWeek with
| DayOfWeek.Saturday | DayOfWeek.Sunday ->
match dt.Month, dt.Day with
| 3, 5 -> false
| _ -> true
| _ ->
match dt.Month, dt.Day with
| 1, 3 | 1, 4 | 1, 5 | 1, 6 | 1, 7 | 1, 10
| 2, 23