Skip to content

Instantly share code, notes, and snippets.

View shawnhyam's full-sized avatar

Shawn Hyam shawnhyam

  • Apple
  • Ottawa, Canada
  • 03:20 - 4h behind
View GitHub Profile
; ___ _ __ ___ __ ___
; / __|_ _ __ _| |_____ / /| __|/ \_ )
; \__ \ ' \/ _` | / / -_) _ \__ \ () / /
; |___/_||_\__,_|_\_\___\___/___/\__/___|
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself
; to learn a little bit about assembly. I **think** I understood everything, but I may
; also be completely wrong :-)
public typealias Reducer<Value, Action, Effect> = (inout Value, Action) -> Command<Effect>
public final class Store<Value, Action>: ObservableObject {
//private let reducer: (inout Value, Action) -> Void
private var _send: ((Action) -> Void)?
@Published public private(set) var value: Value
private var cancellable: Cancellable?
// the reducer for the main Store needs to be generic on <Value, Action, Action>,
// but other reducers are generic on <Value, Action, Effect>
typedef id (^fnType0)();
typedef id (^fnType1)(id);
typedef id (^fnType2)(id, id);
typedef id (^fnType3)(id, id, id);
fnType2 cons = ^id(id car, id cdr) {
return ^(fnType2 m) {
return m(car, cdr);
};
};
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import System.IO
import System.Exit
import System.Environment
import qualified System.ZMQ as ZMQ
import qualified Data.ByteString.UTF8 as SB
import qualified Data.ByteString.Char8 as SB
import Data.List