Skip to content

Instantly share code, notes, and snippets.

@cowlike
Created January 8, 2018 20:51
Show Gist options
  • Save cowlike/9e7cd7f3f03795a50ecc66be1a2eb1b5 to your computer and use it in GitHub Desktop.
Save cowlike/9e7cd7f3f03795a50ecc66be1a2eb1b5 to your computer and use it in GitHub Desktop.
Some utilities & howto
module Util
open System
open System.Collections.Generic
let toGenericList lst = List<_>(List.toSeq lst)
let env =
let envVars =
Environment.GetEnvironmentVariables()
|> Seq.cast<Collections.DictionaryEntry>
|> Seq.map (fun d -> string d.Key, string d.Value)
|> Map.ofSeq
fun key -> Map.tryFind key envVars
let envDef key defVal = Option.defaultValue defVal (env key)
type OptionBuilder() =
member x.Bind(v,f) = Option.bind f v
member x.Return v = Some v
member x.ReturnFrom o = o
member x.Zero() = None
let opt = OptionBuilder()
let flip f x y = f y x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment