Skip to content

Instantly share code, notes, and snippets.

@tLewisII
tLewisII / Reader.swift
Created July 2, 2014 01:55
Try at a Reader Monad in Swift
//this is a playground
struct Reader<R,A> {
let f:R -> A
init(_ fun:R -> A) {
f = fun
}
static func wrap(val:A) -> Reader<R,A> {
return Reader({_ in val})
@mbrandonw
mbrandonw / 1-Functor-and-Monad.md
Last active June 4, 2022 02:12
Swift Functor and Monad

Copy and paste the swift code below into a playground to experiment.

This is a very close emulation of Functor and Monad typeclasses in swift. However, it is very fragile (i.e. easy to crash the compiler).

For example, instance methods of fmap will run fine, but attempting to use a globally defined fmap that acts on Functor types will cause a crash. Similarly for bind. Unfortunately this means we cannot define the nice infix operator versions of these functions.

@joemasilotti
joemasilotti / UI Testing - Mocking Network Data
Last active January 18, 2024 03:35
Xcode UI Testing - How to mock network data
.

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@lifebeyondfife
lifebeyondfife / declarative programming repo problem.cs
Last active June 27, 2024 16:00
Declarative Programming Repo Problem. Problem available in C#, JavaScript and Python.
/*
Code below can be run directly into LINQPad - https://www.linqpad.net/
Return the owner and repo name of the most starred project with more than 100 contributors, for each language
The declarative implementation can be solved using the Select, Where, Aggregate and GroupBy LINQ extension methods
*/
void Main()
{
var repos = new List<Repo> {
@cojoj
cojoj / list.md
Last active November 19, 2020 08:04
Number of people working on iOS apps

Purpose of this list is to gather a source of information on how many people are working on iOS application.
I often wonder how many people are behind Facebook's app or Twitter's. If you're as curious as me, please share and please add apps 😉.

* - it's a rumoured value only. Needs confirmation from someone inside the company.

  1. Fishbrain - 3
  2. Artsy - 5
  3. Truecaller - 5
  4. Lifesum - 4 or 5
  5. Spotify - 50*
@JohnSundell
JohnSundell / AssertThrowsError.swift
Created February 19, 2017 13:36
A function that asserts that an expression throws a given error
/**
* Copyright (c) John Sundell 2017
* Licensed under the MIT license
*/
import Foundation
import XCTest
/**
* Assert that an expression throws a given error
@JadenGeller
JadenGeller / Cluster.swift
Created March 13, 2017 01:27
Class Cluster
class Number /* class cluser */ {
class Int8: Number {
var value: Swift.Int8
init(_ value: Swift.Int8) { self.value = value }
}
class Int: Number {
var value: Swift.Int
init(_ value: Swift.Int) { self.value = value }
}
@AliSoftware
AliSoftware / README-UIKonf17-Talk.md
Last active May 17, 2017 20:46
UIKonf talk - CodeGeneration in Swift - Links & Snippets

This is a reference of all the useful links to follow my UIKonf'17 talk on Code Generation in Swift

@inamiy
inamiy / SwiftElmFrameworkList.md
Last active March 11, 2024 10:20
React & Elm inspired frameworks in Swift