Skip to content

Instantly share code, notes, and snippets.

@alissapajer
alissapajer / gist:50c912d739346c1f00dd
Last active April 1, 2016 06:34
Contravariant and Covariant Functors and Variance of Types over their Type Parameters
/**
* Exercises explaining covariant and contravariant functors.
*
* Additionally exercises explaining variance of types over their type parameters.
*
* Implement the `???` functions. Are all implementable?
*/
trait Functors {
/**
import java.util.concurrent.ConcurrentHashMap
object Why {
val data = new ConcurrentHashMap[Int, String]
def update(int: Int, str: String): Unit = {
data.put(int, str)
}
}
-- https://haskell.fpcomplete.com/user/DanBurton/20-intermediate-exercises
-- Originally from http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
-- Relative Difficulty: 1
instance Fluffy [] where
furry = fmap
@alissapajer
alissapajer / packinglist
Created October 8, 2012 03:36
Rainier packing list!
backpack
pack cover
hiking poles
sleeping bag
sleeping pad
tent
water bottles
camelback
water purification system