This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol IO { | |
associatedtype CollectionType: Collection | |
init(_ source: CollectionType) | |
func go() -> AnyCollection<CollectionType.Element> | |
} | |
struct Print<T> : IO where T: Collection { | |
typealias CollectionType = T | |
let source: CollectionType | |
init(_ source: T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// reduced_problem.swift | |
// swift-parse-playground | |
// | |
// Created by Matt Gadda on 12/27/19. | |
// | |
typealias IO<InputElement, OutputElement> = (AnyCollection<InputElement>) -> AnyCollection<OutputElement>? | |
func printConsumer<T: Collection>(_ source: T) -> AnyCollection<T.Element>? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias Parser<T: Collection, U, T2> = (T) -> (U, T2)? | |
typealias StandardParser<T: Collection, U> = Parser<T, U, T> | |
typealias HomogeneousParser<T: Collection> = StandardParser<T, T> | |
protocol ParserConvertible { | |
associatedtype InputType : Collection = Self | |
associatedtype ParsedValueType = Self | |
associatedtype OutputType = Self | |
func mkParser() -> Parser<InputType, ParsedValueType, OutputType> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias Bar = Foo<Int> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let immutable = Array<Int32>(repeating: 0, count: 4) // => [0, 0, 0, 0] | |
let ptr = UnsafeMutablePointer<Int32>(mutating: immutable) | |
let mutableBuffer = UnsafeMutableBufferPointer(start: ptr, count: immutable.count * MemoryLayout<Int32>.size) | |
let data: Data = Data(bytes: [ | |
0, 0, 0, 0, | |
1, 0, 0, 0, | |
2, 0, 0, 0, | |
3, 0, 0, 0]) | |
data.copyBytes(to: mutableBuffer) | |
immutable // => [0, 1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> swiftc main.swift | |
0 swift 0x00000001094d13ad PrintStackTraceSignalHandler(void*) + 45 | |
1 swift 0x00000001094d0b56 SignalHandler(int) + 790 | |
2 libsystem_platform.dylib 0x00007fffa03fcbba _sigtramp + 26 | |
3 libsystem_platform.dylib 0x00007fdef523a8a8 _sigtramp + 1424219400 | |
4 swift 0x00000001066b979c swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 4492 | |
5 swift 0x00000001066be19e (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 5166 | |
6 swift 0x00000001066ac5f1 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 273 | |
7 swift 0x00000001066fd8b7 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 103 | |
8 swift 0x000000010675dfaa swift::Lowerin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias RealWorld = Int | |
typealias IO<T> = (RealWorld) -> (T, RealWorld) | |
func putStrLn(_ str: String) -> IO<()> { | |
return { (world) in | |
print(str) | |
return ((), world + 1) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Util exposing (..) | |
import Html.Events exposing (on, keyCode) | |
import Html exposing (Attribute) | |
import Json.Decode as Json | |
import Dict exposing (Dict) | |
{-| Conditionally emit msg defined by `tagger` if the | |
key pressed was the enter key. Cannot be used with onEscape. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ignore] | |
[include] | |
[libs] | |
[options] |
NewerOlder