<html xmlns="http://www.w3.org/1999/xhtml" ><head ><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js" ></script ></head ><body ><pre ><span class="hs-pragma" >{-# LANGUAGE Haskell2010 #-}</span ><span > </span ><span id="line-2" ></span ><span class="hs-keyword" >module</span ><span > </span ><span class="hs-identifier" >Classes</span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-3" ></span ><span > </span ><span id="line-4" ></span ><span > </span ><span id="line-5" ></span ><span class="hs-keyword" >class</span ><span > </span ><span id="Foo" ><span class="annot" ><a href="Classes.html#Foo" ><span class="hs-identifier hs-var" >Foo</span ></a ></span ></span ><span > </span ><span id="" ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-6" ></span ><span > </span ><span id="bar" ><span class="annot" ><a href="Classes.html#bar" ><span class="hs-identifier hs-type" >bar</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >::</span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><span class="hs-identifier hs-type" >Int</span ></span ><span > </span ><span id="line-7" ></span ><span > </span ><span id="baz" ><span class="annot" ><a href="Classes.html#baz" ><span class="hs-identifier hs-type" >baz</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >::</span ><span > </span ><span class="annot" ><span class="hs-identifier hs-type" >Int</span ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >,</span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >)</span ><span > </span ><span id="line-8" ></span ><span > </span ><span id="line-9" ></span ><span class="hs-keyword" >instance</span ><span > </span ><span class="annot" ><a href="Classes.html#Foo" ><span class="hs-identifier hs-type" >Foo</span ></a ></span ><span > </span ><span class="annot" ><span class="hs-identifier hs-type" >Int</span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-10" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >bar :: Int -> Int </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >bar</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >Int -> Int forall a. a -> a </span ><span class="hs-identifier hs-var" >id</span ></span ><span > </span ><span id="line-11" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >baz :: Int -> (Int, Int) </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >baz</span ></a ></span ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >Int </span ><a href="#" ><span class="hs-identifier hs-var" >x</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><span class="annottext" >Int </span ><a href="#" ><span class="hs-identifier hs-var" >x</span ></a ></span ><span class="hs-special" >,</span ><span > </span ><span class="annot" ><span class="annottext" >Int </span ><a href="#" ><span class="hs-identifier hs-var" >x</span ></a ></span ><span class="hs-special" >)</span ><span > </span ><span id="line-12" ></span ><span > </span ><span id="line-13" ></span ><span class="hs-keyword" >instance</span ><span > </span ><span id="" ><span class="annot" ><a href="Classes.html#Foo" ><span class="hs-identifier hs-type" >Foo</span ></a ></span ><span > </span ><span class="hs-special" >[</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >]</span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-14" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >bar :: [a] -> Int </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >bar</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >[a] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int </span ><span class="hs-identifier hs-var" >length</span ></span ><span > </span ><span id="line-15" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >baz :: Int -> ([a], [a]) </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >baz</span ></a ></span ></span ><span > </span ><span class="annot" ><span class="annottext" >Int </span ><span class="hs-identifier" >_</span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="hs-special" >(</span ><span class="hs-special" >[</span ><span class="hs-special" >]</span ><span class="hs-special" >,</span ><span > </span ><span class="hs-special" >[</span ><span class="hs-special" >]</span ><span class="hs-special" >)</span ><span > </span ><span id="line-16" ></span ><span > </span ><span id="line-17" ></span ><span > </span ><span id="line-18" ></span ><span class="hs-keyword" >class</span ><span > </span ><span class="annot" ><a href="Classes.html#Foo" ><span class="hs-identifier hs-type" >Foo</span ></a ></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span class="hs-glyph" >=></span ><span > </span ><span id="Foo%27" ><span class="annot" ><a href="Classes.html#Foo%27" ><span class="hs-identifier hs-var" >Foo'</span ></a ></span ></span ><span > </span ><span id="" ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-19" ></span ><span > </span ><span id="quux" ><span class="annot" ><a href="Classes.html#quux" ><span class="hs-identifier hs-type" >quux</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >::</span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >,</span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >)</span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span id="line-20" ></span ><span > </span ><span id="" ><span class="annot" ><a href="Classes.html#quux" ><span class="hs-identifier hs-var hs-var" >quux</span ></a ></span ><span > </span ><span class="hs-special" >(</span ><span id="" ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >x</span ></a ></span ></span ><span class="hs-special" >,</span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >y</span ></a ></span ></span ><span class="hs-special" >)</span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >[a] -> a forall a. Foo' a => [a] -> a </span ><a href="Classes.html#norf" ><span class="hs-identifier hs-var" >norf</span ></a ></span ><span > </span ><span class="hs-special" >[</span ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >x</span ></a ></span ><span class="hs-special" >,</span ><span > </span ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >y</span ></a ></span ><span class="hs-special" >]</span ></span ><span > </span ><span id="line-21" ></span ><span > </span ><span id="line-22" ></span ><span > </span ><span id="norf" ><span class="annot" ><a href="Classes.html#norf" ><span class="hs-identifier hs-type" >norf</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >::</span ><span > </span ><span class="hs-special" >[</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >]</span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span id="line-23" ></span ><span > </span ><span id="" ><span class="annot" ><a href="Classes.html#norf" ><span class="hs-identifier hs-var hs-var" >norf</span ></a ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >(a, a) -> a forall a. Foo' a => (a, a) -> a </span ><a href="Classes.html#quux" ><span class="hs-identifier hs-var" >quux</span ></a ></span ><span > </span ><span class="annot" ><span class="annottext" >((a, a) -> a) -> ([a] -> (a, a)) -> [a] -> a forall b c a. (b -> c) -> (a -> b) -> a -> c </span ><span class="hs-operator hs-var" >.</span ></span ><span > </span ><span class="annot" ><span class="annottext" >Int -> (a, a) forall a. Foo a => Int -> (a, a) </span ><a href="Classes.html#baz" ><span class="hs-identifier hs-var" >baz</span ></a ></span ><span > </span ><span class="annot" ><span class="annottext" >(Int -> (a, a)) -> ([a] -> Int) -> [a] -> (a, a) forall b c a. (b -> c) -> (a -> b) -> a -> c </span ><span class="hs-operator hs-var" >.</span ></span ><span > </span ><span class="annot" ><span class="annottext" >[Int] -> Int forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a </span ><span class="hs-identifier hs-var" >sum</span ></span ><span > </span ><span class="annot" ><span class="annottext" >([Int] -> Int) -> ([a] -> [Int]) -> [a] -> Int forall b c a. (b -> c) -> (a -> b) -> a -> c </span ><span class="hs-operator hs-var" >.</span ></span ><span > </span ><span class="annot" ><span class="annottext" >(a -> Int) -> [a] -> [Int] forall a b. (a -> b) -> [a] -> [b] </span ><span class="hs-identifier hs-var" >map</span ></span ><span > </span ><span class="annot" ><span class="annottext" >a -> Int forall a. Foo a => a -> Int </span ><a href="Classes.html#bar" ><span class="hs-identifier hs-var" >bar</span ></a ></span ></span ><span > </span ><span id="line-24" ></span ><span > </span ><span id="line-25" ></span ><span class="hs-keyword" >instance</span ><span > </span ><span id="" ><span class="annot" ><a href="Classes.html#Foo%27" ><span class="hs-identifier hs-type" >Foo'</span ></a ></span ><span > </span ><span class="annot" ><span class="hs-identifier hs-type" >Int</span ></span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-26" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >norf :: [Int] -> Int </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >norf</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >[Int] -> Int forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a </span ><span class="hs-identifier hs-var" >sum</span ></span ><span > </span ><span id="line-27" ></span ><span > </span ><span id="line-28" ></span ><span class="hs-keyword" >instance</span ><span > </span ><span id="" ><span id="" ><span class="annot" ><a href="Classes.html#Foo%27" ><span class="hs-identifier hs-type" >Foo'</span ></a ></span ><span > </span ><span class="hs-special" >[</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >]</span ></span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-29" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >quux :: ([a], [a]) -> [a] </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >quux</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >([a] -> [a] -> [a]) -> ([a], [a]) -> [a] forall a b c. (a -> b -> c) -> (a, b) -> c </span ><span class="hs-identifier hs-var" >uncurry</span ></span ><span > </span ><span class="annot" ><span class="annottext" >[a] -> [a] -> [a] forall a. [a] -> [a] -> [a] </span ><span class="hs-operator hs-var" >(++)</span ></span ><span > </span ><span id="line-30" ></span ><span > </span ><span id="line-31" ></span ><span > </span ><span id="line-32" ></span ><span class="hs-keyword" >class</span ><span > </span ><span id="Plugh" ><span class="annot" ><a href="Classes.html#Plugh" ><span class="hs-identifier hs-var" >Plugh</span ></a ></span ></span ><span > </span ><span id="" ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >p</span ></a ></span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-33" ></span ><span > </span ><span id="plugh" ><span class="annot" ><a href="Classes.html#plugh" ><span class="hs-identifier hs-type" >plugh</span ></a ></span ></span ><span > </span ><span class="hs-glyph" >::</span ><span > </span ><span id="" ><span id="" ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >p</span ></a ></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >p</span ></a ></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >b</span ></a ></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >b</span ></a ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >p</span ></a ></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >b</span ></a ></span ><span class="hs-special" >)</span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >b</span ></a ></span ><span > </span ><span class="hs-glyph" >-></span ><span > </span ><span class="annot" ><a href="#" ><span class="hs-identifier hs-type" >a</span ></a ></span ><span class="hs-special" >)</span ></span ></span ><span > </span ><span id="line-34" ></span ><span > </span ><span id="line-35" ></span ><span class="hs-keyword" >instance</span ><span > </span ><span class="annot" ><a href="Classes.html#Plugh" ><span class="hs-identifier hs-type" >Plugh</span ></a ></span ><span > </span ><span class="annot" ><span class="hs-identifier hs-type" >Either</span ></span ><span > </span ><span class="hs-keyword" >where</span ><span > </span ><span id="line-36" ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >plugh :: forall a b. Either a a -> Either b b -> Either (a -> b) (b -> a) </span ><a href="#" ><span class="hs-identifier hs-var hs-var hs-var hs-var" >plugh</span ></a ></span ></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><span class="hs-identifier hs-type" >Left</span ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >a</span ></a ></span ></span ><span class="hs-special" >)</span ><span > </span ><span class="annot" ><span class="annottext" >Either b b </span ><span class="hs-identifier" >_</span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >(b -> a) -> Either (a -> b) (b -> a) forall a b. b -> Either a b </span ><span class="hs-identifier hs-var" >Right</span ></span ><span > </span ><span class="annot" ><span class="annottext" >((b -> a) -> Either (a -> b) (b -> a)) -> (b -> a) -> Either (a -> b) (b -> a) forall a b. (a -> b) -> a -> b </span ><span class="hs-operator hs-var" >$</span ></span ><span > </span ><span class="annot" ><span class="annottext" >a -> b -> a forall a b. a -> b -> a </span ><span class="hs-identifier hs-var" >const</span ></span ><span > </span ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >a</span ></a ></span ><span > </span ><span id="line-37" ></span ><span > </span ><span class="annot" ><a href="Classes.html#plugh" ><span class="hs-identifier hs-var" >plugh</span ></a ></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><span class="hs-identifier hs-type" >Right</span ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >a</span ></a ></span ></span ><span class="hs-special" >)</span ><span > </span ><span class="annot" ><span class="annottext" >Either b b </span ><span class="hs-identifier" >_</span ></span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >(b -> a) -> Either (a -> b) (b -> a) forall a b. b -> Either a b </span ><span class="hs-identifier hs-var" >Right</span ></span ><span > </span ><span class="annot" ><span class="annottext" >((b -> a) -> Either (a -> b) (b -> a)) -> (b -> a) -> Either (a -> b) (b -> a) forall a b. (a -> b) -> a -> b </span ><span class="hs-operator hs-var" >$</span ></span ><span > </span ><span class="annot" ><span class="annottext" >a -> b -> a forall a b. a -> b -> a </span ><span class="hs-identifier hs-var" >const</span ></span ><span > </span ><span class="annot" ><span class="annottext" >a </span ><a href="#" ><span class="hs-identifier hs-var" >a</span ></a ></span ><span > </span ><span id="line-38" ></span ><span > </span ><span class="annot" ><a href="Classes.html#plugh" ><span class="hs-identifier hs-var" >plugh</span ></a ></span ><span > </span ><span class="annot" ><span class="annottext" >Either a a </span ><span class="hs-identifier" >_</span ></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><span class="hs-identifier hs-type" >Left</span ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >b </span ><a href="#" ><span class="hs-identifier hs-var" >b</span ></a ></span ></span ><span class="hs-special" >)</span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >(a -> b) -> Either (a -> b) (b -> a) forall a b. a -> Either a b </span ><span class="hs-identifier hs-var" >Left</span ></span ><span > </span ><span class="annot" ><span class="annottext" >((a -> b) -> Either (a -> b) (b -> a)) -> (a -> b) -> Either (a -> b) (b -> a) forall a b. (a -> b) -> a -> b </span ><span class="hs-operator hs-var" >$</span ></span ><span > </span ><span class="annot" ><span class="annottext" >b -> a -> b forall a b. a -> b -> a </span ><span class="hs-identifier hs-var" >const</span ></span ><span > </span ><span class="annot" ><span class="annottext" >b </span ><a href="#" ><span class="hs-identifier hs-var" >b</span ></a ></span ><span > </span ><span id="line-39" ></span ><span > </span ><span class="annot" ><a href="Classes.html#plugh" ><span class="hs-identifier hs-var" >plugh</span ></a ></span ><span > </span ><span class="annot" ><span class="annottext" >Either a a </span ><span class="hs-identifier" >_</span ></span ><span > </span ><span class="hs-special" >(</span ><span class="annot" ><span class="hs-identifier hs-type" >Right</span ></span ><span > </span ><span id="" ><span class="annot" ><span class="annottext" >b </span ><a href="#" ><span class="hs-identifier hs-var" >b</span ></a ></span ></span ><span class="hs-special" >)</span ><span > </span ><span class="hs-glyph" >=</span ><span > </span ><span class="annot" ><span class="annottext" >(a -> b) -> Either (a -> b) (b -> a) forall a b. a -> Either a b </span ><span class="hs-identifier hs-var" >Left</span ></span ><span > </span ><span class="annot" ><span class="annottext" >((a -> b) -> Either (a -> b) (b -> a)) -> (a -> b) -> Either (a -> b) (b -> a) forall a b. (a -> b) -> a -> b </span ><span class="hs-operator hs-var" >$</span ></span ><span > </span ><span class="annot" ><span class="annottext" >b -> a -> b forall a b. a -> b -> a </span ><span class="hs-identifier hs-var" >const</span ></span ><span > </span ><span class="annot" ><span class="annottext" >b </span ><a href="#" ><span class="hs-identifier hs-var" >b</span ></a ></span ><span > </span ><span id="line-40" ></span ></pre ></body ></html >