Symbols | Operations | Laws |
---|---|---|
0, 1, 2, x, y, z, ... | +, –, x, ÷, ... | 0 + x = x, ... |
Symbols | Operations | Laws |
---|
{-# language FlexibleContexts #-} | |
{-# language TypeOperators #-} | |
module DKT where | |
import Control.Monad (guard) | |
import Control.Monad.Error.Class (throwError) | |
import Control.Monad.Trans (lift) | |
import Control.Monad.Trans.State | |
import Control.Monad.Trans.Writer |
# Turn on the simulator screen capture | |
xcrun simctl io booted recordVideo ~/simulator.mov | |
# Convert the iPhone 6s screen shot into a gif: | |
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif |
import Foundation | |
typealias AnyDictionary = [String: Any] | |
typealias AnyArray = [Any] | |
enum PathSeparator { | |
case character(Character) | |
case custom((String) -> [String]) | |
func separate(path: String) -> [String] { |
//: A Cocoa based Playground to present user interface | |
import SwiftUI | |
import PlaygroundSupport | |
struct ContentView: View { | |
var body: some View { | |
HStack { | |
VStack { | |
HStack { |
{-# language PolyKinds #-} | |
{-# language BlockArguments #-} | |
{-# language AllowAmbiguousTypes #-} | |
{-# language StrictData #-} | |
{-# language DerivingStrategies #-} | |
{-# language GeneralizedNewtypeDeriving #-} | |
{-# language TypeApplications #-} | |
{-# language BangPatterns #-} | |
{-# language NPlusKPatterns #-} | |
{-# language TypeFamilies #-} |
protocol P { var pop: String { get } } | |
extension P { | |
var pop: String { "slow" } | |
var pop1: String { pop } | |
} | |
protocol Q: P {} | |
extension Q { var pop: String { "fastQ" } } | |
protocol R: P {} |
import UIKit | |
import Validated | |
extension Validated { | |
func mapErrors<LocalError>(_ transform: (Error) -> LocalError) -> Validated<Value, LocalError> { | |
switch self { | |
case let .valid(value): | |
return .valid(value) | |
case let .invalid(errors): | |
return .invalid(errors.map(transform)) |
Symbols | Operations | Laws |
---|---|---|
0, 1, 2, x, y, z, ... | +, –, x, ÷, ... | 0 + x = x, ... |
Symbols | Operations | Laws |
---|
{-# LANGUAGE DeriveFunctor #-} | |
module Main where | |
type Algebra f a = f a -> a | |
type Coalgebra f a = a -> f a | |
newtype Fix f = In { out :: f (Fix f) } |
protocol Functor { | |
func fmap <A, B> (Self<A>, A -> B) -> Self<B> | |
// ^ ERROR: Cannot specialize non-generic type '`Self`' | |
} | |
enum Maybe<A> : Functor { | |
case Nothing | |
case Just(A) | |
func fmap<B>(x: Maybe<A>, f: A -> B) -> Maybe<B> { |