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
public static Option<TException> WithoutValue<TValue, TException>(this Option<TValue, TException> option) | |
{ | |
return option.Match(_ => Option.None<TException>(), exception => exception.Some()); | |
} | |
public static IEnumerable<TValue> Values<TValue, TException>(this IEnumerable<Option<TValue, TException>> source) | |
{ | |
if (source == null) throw new ArgumentNullException(nameof(source)); | |
return source.SelectMany(option => option.ToEnumerable()); | |
} |
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
// Learn more about F# at http://fsharp.org | |
// See the 'F# Tutorial' project for more help. | |
open System | |
let toInt a = | |
match (Int32.TryParse(a)) with | |
| (true, x) -> Some x | |
| (false, _) -> None | |
type MaybeBuilder() = |
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
open System | |
let divideBy bottom top = | |
if bottom = 0 | |
then None | |
else Some(top/bottom) | |
type MaybeBuilder() = | |
member this.Bind(x, f) = |
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 Result = | |
type Result<'TResult, 'TError> = | |
| Ok of 'TResult | |
| Error of 'TError | |
let ifNone (error : 'TError) = function | |
| Some (o) -> Ok o | |
| None -> Error error | |
let map f = function |
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
type MayBeBuilder() = | |
member x.Bind(v,f) = Option.bind f v | |
member x.Return v = Some v | |
member x.ReturnFrom o = o | |
let maybe = OptionBuilder() |
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
export function flatten<T>(array: T[][]): T[] { | |
return [].concat.apply([], array); | |
} | |
export function chunk<T>( | |
array: T[], | |
chunkSize: number, | |
acc: T[][] = [] | |
): T[][] { | |
return array.length > chunkSize |
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
declare module "react-throttle" { | |
export interface DebounceProps extends React.Props<Debounce> { | |
time: number; | |
handler: string; | |
} | |
export class Debounce extends React.Component<DebounceProps> {} | |
} |
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
let getXsd id = | |
query { | |
for messageItem in ctx.ProtoType.MessageType do | |
for originalMessage in messageItem.``ProtoType.OriginalMessage by Id`` do | |
for messageType in originalMessage.``ProtoType.MessageType by Id`` do | |
where (messageItem.Id = id) | |
select (messageType.Xsd) | |
} |> Seq.head |
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
open Giraffe.HttpHandlers | |
open Microsoft.AspNetCore.WebUtilities | |
open System.IO | |
open System | |
let isMultipartContentType (contentType:string) = | |
not(String.IsNullOrEmpty(contentType)) && | |
contentType.IndexOf("multipart/", StringComparison.OrdinalIgnoreCase) >= 0 | |
let getBoundary (contentType : string) = |
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
const $ = (selector) => { | |
return Array.prototype.slice.call(document.querySelectorAll(selector)); | |
} |