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
| // code from https://stackoverflow.com/questions/6736464/split-seq-in-f/6737659#6737659 | |
| let splitBy f input = | |
| let i = ref 0 | |
| input | |
| |> Seq.groupBy (fun x -> | |
| if f x then incr i | |
| !i) | |
| |> Seq.map snd |
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 RZ.OptionParser | |
| open System | |
| open System.Collections.Generic | |
| type Handler<'ctx> = 'ctx -> string -> 'ctx | |
| let fst3 (x,_,_) = x | |
| let snd3 (_,x,_) = x | |
| let thd (_,_,x) = x |
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 flip f a b = f b a | |
| type Car = { | |
| name: string | |
| horsepower: int | |
| dollar_value: double | |
| in_stock: bool | |
| } | |
| [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] |
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
| var Promise__map = function(g){ // g: a -> b | |
| var _f = function(){}; | |
| var h = function(f){ // h : (b -> c) -> 0 | |
| _f = f; | |
| }; | |
| this.fp(function(a){ | |
| var b = g(a); | |
| _f(b); | |
| return b; | |
| }); |
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; | |
| namespace RZ.Extensions{ | |
| public class DisposableProxy : IDisposable{ | |
| public static readonly IDisposable Dummy = new DisposableProxy(delegate {}); | |
| readonly Action dispose; | |
| public DisposableProxy(Action dispose){ | |
| this.dispose = dispose; | |
| } | |
| public void 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
| module RZ.String | |
| /// <summary> | |
| /// New Non-blank string | |
| /// </summary> | |
| type NBString = NBString of string | |
| [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | |
| module NBString = | |
| let from s = | |
| if String.IsNullOrWhiteSpace s then invalidArg "s" "String cannot be blank or empty" |
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 System.Runtime.CompilerServices | |
| #nowarn "46" // no warning for using reserved word "pure" | |
| type IOError<'T> = Result<'T, exn> | |
| type IO<'T> = unit -> IOError<'T> | |
| exception UnwrapError of obj | |
| type Option<'a> with |
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 RZ.Pair | |
| let inline ofSame a = (a,a) | |
| let inline of' a b = (a,b) | |
| let inline with' b a = (a,b) | |
| let inline sndWith a b = (a,b) | |
| let inline call f (a,b) = f(a,b) | |
| let inline map f (a,b) = (f a, f b) | |
| let inline fapply (f,g) x = (f x, g x) | |
| let inline cross (a,b) x = ((a,x), (b,x)) |
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
| 'use strict'; | |
| var gulp = require('gulp'); | |
| var gutil = require('gulp-util'); | |
| var source = require('vinyl-source-stream'); | |
| var R = require('ramda'); | |
| // Browserify example from: https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md | |
| var browserify = require('browserify'); | |
| var watchify = require('watchify'); |
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
| // ref: http://bugsquash.blogspot.com/2010/12/zipping-with-applicative-functors-in-f.html | |
| module SeqApplicative = | |
| let puree v = Seq.initInfinite (fun _ -> v) | |
| let (<*>) f a = Seq.zip f a |> Seq.map (fun (f', a') -> f' a') | |
| let (<!>) f a = puree f <*> a |
OlderNewer