Skip to content

Instantly share code, notes, and snippets.

View johnazariah's full-sized avatar

John Azariah johnazariah

  • Microsoft Corporation
  • Brisbane, Queensland, Australia
  • 01:27 (UTC +10:00)
View GitHub Profile
type LF = (Argument, State) => (State, Result)
case class _then(f : LF)
case class _else(f : LF)
def _if (ifFunc: LF) (thenFunc: _then) (elseFunc: _else) : LF =
(a, state) => ifFunc(a, state) match {
case (_, Accepted) => thenFunc.f(a, state)
case _ => elseFunc.f(a, state)
}
public class Program
{
public void Main()
{
var solution = new Directory
{
["global.json"] = new JObject
{
["projects"] = new JArray { "src", "test" }
},
[<AutoOpen>]
module SuccessOrFailure =
type SuccessOrFailure<'a> =
| Success of 'a
| Failure of exn
let point v = Success v
let (>>=) m f =
match m with
@johnazariah
johnazariah / .bash_profile
Last active August 27, 2020 12:58
Git Aliases
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
using System;
namespace FSM.BankAccount
{
public abstract class BankAccountState
{
public static readonly BankAccountState ZeroBalanceState = new ChoiceTypes.ZeroBalanceState();
public static readonly BankAccountState ActiveState = new ChoiceTypes.ActiveState();
public static readonly BankAccountState OverdrawnState = new ChoiceTypes.OverdrawnState();
public static readonly BankAccountState ClosedState = new ChoiceTypes.ClosedState();
@johnazariah
johnazariah / maybe.fs
Created December 31, 2016 14:01
Maybe Computation Expression Builder
namespace Utility.Monads
[<AutoOpen>]
module MaybeMonad =
type MaybeBuilder() =
member this.Zero() = this.Return ()
member this.Bind(m, f) = Option.bind f m
member this.Return(x) = Some x
member this.ReturnFrom(x) = x
member this.Yield(x) = Some x
@johnazariah
johnazariah / .bash_profile
Last active April 11, 2025 00:55
Git Configuration
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
#from http://stackoverflow.com/questions/33220492/ps1-bash-command-substitution-not-working-on-windows-10
# Reset
Off="\[\e[0m\]" # Text Reset
# Regular Colors
@johnazariah
johnazariah / Tree.fs
Created December 22, 2017 18:02
Monkeying Around : Fun With Trees
module Tree =
type NodeId = | Id of string
with
member this.unapply = match this with | Id x -> x
[<AutoOpen>]
module internal Node =
[<AbstractClass>]
type NodeBase<'a> () = class
member val internal Children : NodeBase<'a> list = [] with get, set
@johnazariah
johnazariah / free.fs
Created April 3, 2018 22:02
Free Monad with Trampoline Infrastructure and Computation Builder
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b>
type F<'a> = QIL<'a>
and S<'a> = F<Q<'a>>
and Q<'a> =
private
| Step of Step<'a>
| Bind of IBind<'a>
with
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k))
@johnazariah
johnazariah / Helpers.Client.cs
Last active July 30, 2018 16:55
Getting Started with Orleans 2.0 on .NET Core
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Configuration;
using Orleans.Hosting;
using System;
using System.Threading.Tasks;
namespace Orleans2GettingStarted
{
internal static class ClientDevelopmentHelpers