Skip to content

Instantly share code, notes, and snippets.

@disolovyov
disolovyov / TypeClass.hs
Created October 11, 2012 14:51 — forked from tonymorris/TypeClass.hs
Type-class hierarchy
{-# LANGUAGE NoImplicitPrelude, MultiParamTypeClasses, Rank2Types, TypeOperators #-}
newtype Id a =
Id a
data a :\/ b =
Left a
| Right b
data a :/\ b =
@disolovyov
disolovyov / simple_autoloader.rb
Created September 27, 2010 14:26 — forked from rkh/simple_autoloader.rb
Autoloading with namespaces
# Extremely simple autoloading implementation
class Module
alias const_missing_without_autoloading const_missing
def const_missing(const)
path = "#{name.gsub('::', '/')}/#{const}"
path.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
require path.downcase
const_defined?(const) ? const_get(const) : super
rescue LoadError => error
warn(error.message)