Skip to content

Instantly share code, notes, and snippets.

class Uncurry fun types r where
uncurryNP :: fun -> NP I types -> r
instance forall fun r t types.
( Uncurry fun types r
) => Uncurry (t -> fun) (t ': types) r where
uncurryNP f ((I a) :* as) = uncurryNP (f a) as
instance (s ~ r) => Uncurry s '[] r where
uncurryNP z Nil = z
@reactormonk
reactormonk / Main.elm
Last active August 11, 2016 14:12 — forked from anonymous/Main.elm
import Html exposing (..)
import Html.App as App
import Html.Events exposing (..)
import List
import Json.Decode as Json
join : List String -> String
join list = (List.foldr (++) "" list)
main : Program Never
@reactormonk
reactormonk / hash.rb
Created December 14, 2011 10:54 — forked from madsheep/hash.rb
Hardcore deep hash
class Hash
define_method '[]_with_try_on', do |*args|
if args.size == 1 and respond_to?(args.first)
send(:'[]_with_try_on', args.first)
else
args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) }
end
end
class RESTController < Controller
def self.object_name=(object_name)
@@object_name = object_name
end
def self.object_name
@@object_name
end
# @api plugin
require 'nokogiri'
app = proc do |env|
doc = Nokogiri::HTML('<html><head></head><body><div id="hello">Hello World</div></body></html>')
body = doc.css('#hello').content
[body, 200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.size.to_s }]
end
run app
class Game
include DataMapper::Resource
#
# Properties
#
property :id, Serial
#
# Associations