This is a curated list of iOS (Swift & ObjC) frameworks which are inspired by React and Elm.
- ReactSwift by @ColinEberhardt
- https://github.com/ColinEberhardt/ReactSwift
import Foundation | |
// A lens is a getter and a setter combined | |
struct Lens<Whole, Part> { | |
let get: (Whole) -> Part | |
let set: (inout Whole, Part) -> () | |
} | |
// We can create a lens from a key path | |
extension Lens { |
This is a curated list of iOS (Swift & ObjC) frameworks which are inspired by React and Elm.
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,
module Main where | |
import Combine exposing (Parser, string, parse, end, andThen, many1, while, many, skip, Result (..)) | |
import Combine.Char exposing (noneOf, char) | |
import Combine.Num exposing (int) | |
import Combine.Infix exposing ((<$>), (<$), (<*), (*>), (<*>), (<|>)) | |
import Maybe exposing (Maybe) | |
import History exposing (path, setPath) | |
import Signal exposing (Signal, (<~), (~), send, message) | |
import Effects exposing (Effects, task) |
This document is a collection of concepts and strategies to make large Elm projects modular and extensible.
We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp
. You will probably merge
a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying
require 'axiom-memory-adapter' | |
adapter = Axiom::Adapter::Memory.new( | |
customers: Axiom::Relation.new([[:id, Integer], [:name, String]]), | |
orders: Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]]) | |
) | |
# Insert customer data | |
customers = adapter[:customers] | |
customers.insert([[1, 'Dan Kubb']]) |
;;; Clojure port of http://dysphoria.net/code/hindley-milner/HindleyMilner.scala | |
(ns hindley-milner | |
(:require [clojure.string :as str])) | |
(declare occurs-in? occurs-in-type?) | |
(defn map-state | |
"Evaluate a list of state monad values in sequence, producing | |
a list of the results of each evaluation." |
Installs ruby-2.0.0-p0 on ubuntu via checkinstall so it's in your package manager and you can remove it.
Quick install:
curl -L https://gist.github.com/ngauthier/5039249/raw/1868bf4714052b40e2bb7fdf3f40fbeb5d730bca/ruby-2-install-ubuntu.sh | bash -s
/** | |
* Converts a string to a "URL-safe" slug. | |
* Allows for some customization with two optional parameters: | |
* | |
* @param {string} Delimiter used. If not specified, defaults to a dash "-" | |
* @param {array} Adds to the list of non-alphanumeric characters which | |
* will be converted to the delimiter. The default list includes: | |
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' '] | |
*/ | |
if (!String.prototype.slugify) { |