Created
January 8, 2018 20:51
-
-
Save cowlike/9e7cd7f3f03795a50ecc66be1a2eb1b5 to your computer and use it in GitHub Desktop.
Some utilities & howto
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 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