Use Runes for functional operators

This commit is contained in:
Reda Lemeden 2015-01-20 20:44:15 +01:00
parent c51f0f7cbd
commit d6a7b29aaf
14 changed files with 53 additions and 99 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ build/
*.dat
*.dep
.DS_Store
Carthage/Build

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Carthage/Checkouts/runes"]
path = Carthage/Checkouts/runes
url = https://github.com/thoughtbot/runes.git

1
Cartfile Normal file
View File

@ -0,0 +1 @@
github "thoughtbot/runes"

1
Cartfile.resolved Normal file
View File

@ -0,0 +1 @@
github "thoughtbot/runes" "v1.1"

1
Carthage/Checkouts/runes vendored Submodule

@ -0,0 +1 @@
Subproject commit cee6b16f47dc766494dbd998bc17f4ca932e08c3

View File

@ -7,8 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
00B8C8381A36583600C188E7 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00B8C8371A36583000C188E7 /* Gifu.framework */; };
00B8C8391A36583600C188E7 /* Gifu.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 00B8C8371A36583000C188E7 /* Gifu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
005656EB1A6EE471008A0ED1 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 005656EA1A6EE471008A0ED1 /* Gifu.framework */; };
9D25870819BCCB0F00A55A18 /* mugen.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9D25870619BCCB0F00A55A18 /* mugen.gif */; };
9D98823D19BC69CA00B790C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98823C19BC69CA00B790C6 /* AppDelegate.swift */; };
9D98823F19BC69CA00B790C6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98823E19BC69CA00B790C6 /* ViewController.swift */; };
@ -17,23 +16,6 @@
9D98826719BC874C00B790C6 /* FlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98826619BC874C00B790C6 /* FlatButton.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
00B8C8361A36583000C188E7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00B8C8321A36583000C188E7 /* Gifu.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 00B8C73E1A364DA400C188E7;
remoteInfo = Gifu;
};
00B8C83A1A36583600C188E7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00B8C8321A36583000C188E7 /* Gifu.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 00B8C73D1A364DA400C188E7;
remoteInfo = Gifu;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
00B8C7331A364D4C00C188E7 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
@ -41,7 +23,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
00B8C8391A36583600C188E7 /* Gifu.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@ -49,7 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
00B8C8321A36583000C188E7 /* Gifu.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Gifu.xcodeproj; path = ../../Gifu.xcodeproj; sourceTree = "<group>"; };
005656EA1A6EE471008A0ED1 /* Gifu.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gifu.framework; path = "../../build/Debug-iphoneos/Gifu.framework"; sourceTree = "<group>"; };
9D25870519BCCB0F00A55A18 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9D25870619BCCB0F00A55A18 /* mugen.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = mugen.gif; sourceTree = "<group>"; };
9D98823719BC69CA00B790C6 /* gifu-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "gifu-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -65,36 +46,18 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
00B8C8381A36583600C188E7 /* Gifu.framework in Frameworks */,
005656EB1A6EE471008A0ED1 /* Gifu.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
00B8C7621A364E8C00C188E7 /* Frameworks */ = {
isa = PBXGroup;
children = (
00B8C8321A36583000C188E7 /* Gifu.xcodeproj */,
);
name = Frameworks;
path = demo;
sourceTree = "<group>";
};
00B8C8331A36583000C188E7 /* Products */ = {
isa = PBXGroup;
children = (
00B8C8371A36583000C188E7 /* Gifu.framework */,
);
name = Products;
sourceTree = "<group>";
};
9D98822E19BC69CA00B790C6 = {
isa = PBXGroup;
children = (
9D98823919BC69CA00B790C6 /* Source */,
9D98823819BC69CA00B790C6 /* Products */,
00B8C7621A364E8C00C188E7 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -123,6 +86,7 @@
9D98823A19BC69CA00B790C6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
005656EA1A6EE471008A0ED1 /* Gifu.framework */,
9D25870519BCCB0F00A55A18 /* Info.plist */,
9D25870619BCCB0F00A55A18 /* mugen.gif */,
);
@ -144,7 +108,6 @@
buildRules = (
);
dependencies = (
00B8C83B1A36583600C188E7 /* PBXTargetDependency */,
);
name = "gifu-demo";
productName = "gifu-demo";
@ -165,7 +128,7 @@
};
};
};
buildConfigurationList = 9D98823219BC69CA00B790C6 /* Build configuration list for PBXProject "gifu-demo" */;
buildConfigurationList = 9D98823219BC69CA00B790C6 /* Build configuration list for PBXProject "Demo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
@ -176,12 +139,6 @@
mainGroup = 9D98822E19BC69CA00B790C6;
productRefGroup = 9D98823819BC69CA00B790C6 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 00B8C8331A36583000C188E7 /* Products */;
ProjectRef = 00B8C8321A36583000C188E7 /* Gifu.xcodeproj */;
},
);
projectRoot = "";
targets = (
9D98823619BC69CA00B790C6 /* gifu-demo */,
@ -189,16 +146,6 @@
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
00B8C8371A36583000C188E7 /* Gifu.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Gifu.framework;
remoteRef = 00B8C8361A36583000C188E7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
9D98823519BC69CA00B790C6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
@ -225,14 +172,6 @@
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
00B8C83B1A36583600C188E7 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = Gifu;
targetProxy = 00B8C83A1A36583600C188E7 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
9D98825119BC69CA00B790C6 /* Debug */ = {
isa = XCBuildConfiguration;
@ -317,6 +256,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -330,6 +270,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@ -340,7 +281,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
9D98823219BC69CA00B790C6 /* Build configuration list for PBXProject "gifu-demo" */ = {
9D98823219BC69CA00B790C6 /* Build configuration list for PBXProject "Demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9D98825119BC69CA00B790C6 /* Debug */,

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Demo.xcodeproj">
</FileRef>
<FileRef
location = "group:../Gifu.xcodeproj">
</FileRef>
<FileRef
location = "group:../Carthage/Checkouts/runes/Runes.xcodeproj">
</FileRef>
</Workspace>

View File

@ -7,16 +7,18 @@
objects = {
/* Begin PBXBuildFile section */
006F97011A6EDE7900CB5CE8 /* Runes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 006F97001A6EDE7900CB5CE8 /* Runes.framework */; };
00B8C75E1A364DCE00C188E7 /* AnimatedImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B8C75B1A364DCE00C188E7 /* AnimatedImage.swift */; };
00B8C75F1A364DCE00C188E7 /* ImageSourceHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B8C75C1A364DCE00C188E7 /* ImageSourceHelpers.swift */; };
00B8C7601A364DCE00C188E7 /* UIImageView+Gifu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00B8C75D1A364DCE00C188E7 /* UIImageView+Gifu.swift */; };
00B8C7961A3650EE00C188E7 /* Gifu.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B8C7951A3650EE00C188E7 /* Gifu.h */; settings = {ATTRIBUTES = (Public, ); }; };
EAF49C7F1A3A4DE000B395DF /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C7E1A3A4DE000B395DF /* UIImageExtension.swift */; };
EAF49C811A3A4FAA00B395DF /* Functional.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C801A3A4FAA00B395DF /* Functional.swift */; };
EAF49C811A3A4FAA00B395DF /* Curry.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C801A3A4FAA00B395DF /* Curry.swift */; };
EAF49CB11A3B6EEB00B395DF /* AnimatedFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
006F97001A6EDE7900CB5CE8 /* Runes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Runes.framework; path = "../Carthage/Checkouts/runes/build/Debug-iphoneos/Runes.framework"; sourceTree = "<group>"; };
00B8C73E1A364DA400C188E7 /* Gifu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Gifu.framework; sourceTree = BUILT_PRODUCTS_DIR; };
00B8C7421A364DA400C188E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Source/Info.plist; sourceTree = "<group>"; };
00B8C75B1A364DCE00C188E7 /* AnimatedImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedImage.swift; sourceTree = "<group>"; };
@ -24,7 +26,7 @@
00B8C75D1A364DCE00C188E7 /* UIImageView+Gifu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImageView+Gifu.swift"; sourceTree = "<group>"; };
00B8C7951A3650EE00C188E7 /* Gifu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gifu.h; sourceTree = "<group>"; };
EAF49C7E1A3A4DE000B395DF /* UIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = "<group>"; };
EAF49C801A3A4FAA00B395DF /* Functional.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Functional.swift; sourceTree = "<group>"; };
EAF49C801A3A4FAA00B395DF /* Curry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Curry.swift; sourceTree = "<group>"; };
EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedFrame.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -33,6 +35,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
006F97011A6EDE7900CB5CE8 /* Runes.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -59,6 +62,7 @@
00B8C7411A364DA400C188E7 /* Supporting Files */ = {
isa = PBXGroup;
children = (
006F97001A6EDE7900CB5CE8 /* Runes.framework */,
00B8C7421A364DA400C188E7 /* Info.plist */,
);
name = "Supporting Files";
@ -73,7 +77,7 @@
00B8C75C1A364DCE00C188E7 /* ImageSourceHelpers.swift */,
00B8C75D1A364DCE00C188E7 /* UIImageView+Gifu.swift */,
EAF49C7E1A3A4DE000B395DF /* UIImageExtension.swift */,
EAF49C801A3A4FAA00B395DF /* Functional.swift */,
EAF49C801A3A4FAA00B395DF /* Curry.swift */,
EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */,
);
path = Source;
@ -160,7 +164,7 @@
EAF49CB11A3B6EEB00B395DF /* AnimatedFrame.swift in Sources */,
00B8C7601A364DCE00C188E7 /* UIImageView+Gifu.swift in Sources */,
00B8C75F1A364DCE00C188E7 /* ImageSourceHelpers.swift in Sources */,
EAF49C811A3A4FAA00B395DF /* Functional.swift in Sources */,
EAF49C811A3A4FAA00B395DF /* Curry.swift in Sources */,
00B8C75E1A364DCE00C188E7 /* AnimatedImage.swift in Sources */,
EAF49C7F1A3A4DE000B395DF /* UIImageExtension.swift in Sources */,
);
@ -262,6 +266,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -280,6 +285,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Gifu.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/runes/Runes.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,5 +1,6 @@
import UIKit
import ImageIO
import Runes
public class AnimatedImage: UIImage {
// MARK: - Constants

3
Source/Curry.swift Normal file
View File

@ -0,0 +1,3 @@
func curry<A, B, C>(f: (A, B) -> C) -> A -> B -> C {
return { a in { b in f(a, b) } }
}

View File

@ -1,28 +0,0 @@
infix operator >>- { associativity left precedence 150 }
infix operator <^> { associativity left precedence 150 }
infix operator <*> { associativity left precedence 150 }
func >>-<A, B>(a: A?, f: A -> B?) -> B? {
switch a {
case let .Some(x): return f(x)
case .None: return .None
}
}
func <^><A, B>(f: A -> B, a: A?) -> B? {
switch a {
case let .Some(x): return f(x)
case .None: return .None
}
}
func <*><A, B>(f: (A -> B)?, a: A?) -> B? {
switch f {
case let .Some(fx): return fx <^> a
case .None: return .None
}
}
func curry<A, B, C>(f: (A, B) -> C) -> A -> B -> C {
return { a in { b in f(a, b) } }
}

View File

@ -1,6 +1,7 @@
import UIKit
import ImageIO
import MobileCoreServices
import Runes
internal typealias GIFProperties = [String : Double]
private let defaultDuration: Double = 0