Instance | Branch |
---|
#################################################################################### | |
## ## | |
## gittyup() - Easily keep master in sync with upstream. ## | |
## ## | |
## Author: Evan Coury, http://blog.evan.pro/ ## | |
## URL: https://gist.github.com/1506822 ## | |
## ## | |
## This bash function is a simple shortcut for keeping your local (and public ## | |
## fork / origin remote) master branch up to date and in sync with the upstream ## | |
## master. To use gittyup(), simply drop this in your ~/.bashrc. ## |
By @foldleft.bsky.social, see also Unfollow everyone on bsky.app.
- Go to
https://twitter.com/YOUR_USER_NAME/following
- Open the Developer Console. (COMMAND+ALT+I on Mac)
- Paste this into the Developer Console and run it
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
##A (Haskell) Monad Is...
A monoid in the category of endofunctors...
Such that the following diagrams commute
##Mu Reduction
μT
'GET /api/notifications': 'NotificationController.show', | |
'GET /hacks/isEncoded/:id': 'HacksController.isEncoded', | |
'POST /api/notifications': 'APNSUserController.subscribe', | |
'PUT /api/notifications/:id': 'NotificationController.see', | |
'DELETE /api/notifications/:id': 'NotificationController.destroy', |
I’ve been writing a load of Swift code recently for work and this has lead me into the world of typed functional programming. The app needs to build certain objects from a comma separated string, and this lead me to applicative functors, which lead me to brain ache but enlightenment. So here’s my thoughts on how I got to understand these a little better.
All of the code is in Swift, so less clean than Haskell. I’m also only a about 6 weeks into Swift development so I probably haven’t got all of the idioms right. I’ve avoided the optional shorthand wherever possible here, preferring Optional<Type>
over Type?
because I believe the latter is hiding something that helps understand this code in the context of other generic classes.
It’s also long! I think it’s probably the longest blog post I’ve ever written but I found it interesting and useful, for myself, to write. If you’re one of those people who skip to the end of a book to find out whodunit then I’ve included
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
void (^benchmark)(const char *str) = ^(const char *str) { | |
const long count = 10000000; | |
NSDate *start = [NSDate date]; | |
for (long i = 0; i < count; i++) { | |
(void)[[NSString alloc] initWithUTF8String:str]; | |
} |
/* | |
* attempt takes a function that does not accept optional values | |
* and returns a new function that will work as usual with non-optional values | |
* and return nil when passed an optional value | |
*/ | |
func attempt<T,U>(f: T -> U)-> T? -> U? { | |
return { y in | |
if let x = y { | |
return f(x) |
/* | |
* chain takes in any number of 1-argument functions as arguments | |
* and returns a function that executes each function in order | |
*/ | |
func chain<T>(all: T -> () ...) -> T -> () { | |
return { x in | |
for f in all { f(x) } | |
} | |
} |
extension Bool { | |
init<T : IntegerType>(_ integer: T){ | |
self.init(integer != 0) | |
} | |
} | |
// Now you can do this | |
let x = Bool(5) // true | |
let y = Bool(-1) // true | |
let z = Bool(0) // false |