Skip to content

Instantly share code, notes, and snippets.

View rabzu's full-sized avatar
🤺
Compiling...

rabzu rabzu

🤺
Compiling...
View GitHub Profile
@rabzu
rabzu / FSM.scala
Created October 6, 2019 16:52 — forked from knutwalker/FSM.scala
Simple Encoding of a purely functional Finite State Machine using Scala and scalaz
package example.statemachine
import scalaz.{State, Scalaz}, Scalaz._
object FSM {
def apply[I, S](f: PartialFunction[(I, S), S]): FSM[I, S] =
new FSM((i, s) => f.applyOrElse((i, s), (_: (I, S)) => s))
private def states[S, O](xs: List[State[S, O]]): State[S, List[O]] =
xs.sequence[({type λ[α]=State[S, α]})#λ, O]
@rabzu
rabzu / FSM.scala
Created October 6, 2019 16:52 — forked from knutwalker/FSM.scala
Simple Encoding of a purely functional Finite State Machine using Scala and scalaz
package example.statemachine
import scalaz.{State, Scalaz}, Scalaz._
object FSM {
def apply[I, S](f: PartialFunction[(I, S), S]): FSM[I, S] =
new FSM((i, s) => f.applyOrElse((i, s), (_: (I, S)) => s))
private def states[S, O](xs: List[State[S, O]]): State[S, List[O]] =
xs.sequence[({type λ[α]=State[S, α]})#λ, O]
@rabzu
rabzu / FSM.scala
Created October 6, 2019 16:52 — forked from knutwalker/FSM.scala
Simple Encoding of a purely functional Finite State Machine using Scala and scalaz
package example.statemachine
import scalaz.{State, Scalaz}, Scalaz._
object FSM {
def apply[I, S](f: PartialFunction[(I, S), S]): FSM[I, S] =
new FSM((i, s) => f.applyOrElse((i, s), (_: (I, S)) => s))
private def states[S, O](xs: List[State[S, O]]): State[S, List[O]] =
xs.sequence[({type λ[α]=State[S, α]})#λ, O]
@rabzu
rabzu / NSManagedObject.swift
Last active March 9, 2016 13:31 — forked from vl4dimir/ExtendedManagedObject.h
Swift Version of NSManagedObject_to_Dictionary Extension:
//
// NSManagedObject.swift Extension
// Transfroms CoreData NSManageObject into Swift Dictionary
// The resulting dictionary can be then used for serialization and copying
//
// Created by rabzu on 25/11/2014.
// Copyright (c) 2014 WeshApp. All rights reserved.
//
import Foundation