diff options
author | Łukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-02 19:05:58 +0200 |
---|---|---|
committer | Łukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-02 19:05:58 +0200 |
commit | 29bb1ce86e12b368c4eb91dbf515391a0958b8c3 (patch) | |
tree | 310b9c071ae7f66ee488530f16e6024162900478 /hypsrc-test | |
parent | ef3b8691ea607bd4f67d5dc77bb226cf57ec4c30 (diff) |
Create hyperlinker test case for type classes.
Diffstat (limited to 'hypsrc-test')
-rw-r--r-- | hypsrc-test/ref/src/Classes.html | 931 | ||||
-rw-r--r-- | hypsrc-test/src/Classes.hs | 38 |
2 files changed, 969 insertions, 0 deletions
diff --git a/hypsrc-test/ref/src/Classes.html b/hypsrc-test/ref/src/Classes.html new file mode 100644 index 00000000..a5a3d243 --- /dev/null +++ b/hypsrc-test/ref/src/Classes.html @@ -0,0 +1,931 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<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-keyword" + >module</span + ><span class="" + > </span + ><span class="hs-identifier" + >Classes</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + + +</span + ><span class="hs-keyword" + >class</span + ><span class="" + > </span + ><a name="Foo" + ><a href="Classes.html#Foo" + ><span class="hs-identifier" + >Foo</span + ></a + ></a + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >a</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="bar" + ><a href="Classes.html#bar" + ><span class="hs-identifier" + >bar</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >::</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><span class="hs-identifier hs-type" + >Int</span + ><span class="" + > + </span + ><a name="baz" + ><a href="Classes.html#baz" + ><span class="hs-identifier" + >baz</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >::</span + ><span class="" + > </span + ><span class="hs-identifier hs-type" + >Int</span + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >)</span + ><span class="" + > + +</span + ><span class="hs-keyword" + >instance</span + ><span class="" + > </span + ><a href="Classes.html#Foo" + ><span class="hs-identifier hs-type" + >Foo</span + ></a + ><span class="" + > </span + ><span class="hs-identifier hs-type" + >Int</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#bar" + ><span class="hs-identifier" + >bar</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >id</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#baz" + ><span class="hs-identifier" + >baz</span + ></a + ></a + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >x</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >x</span + ></a + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >x</span + ></a + ><span class="hs-special" + >)</span + ><span class="" + > + +</span + ><span class="hs-keyword" + >instance</span + ><span class="" + > </span + ><a href="Classes.html#Foo" + ><span class="hs-identifier hs-type" + >Foo</span + ></a + ><span class="" + > </span + ><span class="hs-special" + >[</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >]</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#bar" + ><span class="hs-identifier" + >bar</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >length</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#baz" + ><span class="hs-identifier" + >baz</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-identifier" + >_</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-special" + >[</span + ><span class="hs-special" + >]</span + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><span class="hs-special" + >[</span + ><span class="hs-special" + >]</span + ><span class="hs-special" + >)</span + ><span class="" + > + + +</span + ><span class="hs-keyword" + >class</span + ><span class="" + > </span + ><a href="Classes.html#Foo" + ><span class="hs-identifier hs-type" + >Foo</span + ></a + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=></span + ><span class="" + > </span + ><a name="Foo%27" + ><a href="Classes.html#Foo%27" + ><span class="hs-identifier" + >Foo'</span + ></a + ></a + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >a</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="quux" + ><a href="Classes.html#quux" + ><span class="hs-identifier" + >quux</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >::</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#quux" + ><span class="hs-identifier" + >quux</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >x</span + ></a + ></a + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >y</span + ></a + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><a href="Classes.html#norf" + ><span class="hs-identifier hs-var" + >norf</span + ></a + ><span class="" + > </span + ><span class="hs-special" + >[</span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >x</span + ></a + ><span class="hs-special" + >,</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >y</span + ></a + ><span class="hs-special" + >]</span + ><span class="" + > + + </span + ><a name="norf" + ><a href="Classes.html#norf" + ><span class="hs-identifier" + >norf</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >::</span + ><span class="" + > </span + ><span class="hs-special" + >[</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >]</span + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#norf" + ><span class="hs-identifier" + >norf</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><a href="Classes.html#quux" + ><span class="hs-identifier hs-var" + >quux</span + ></a + ><span class="" + > </span + ><span class="hs-operator hs-var" + >.</span + ><span class="" + > </span + ><a href="Classes.html#baz" + ><span class="hs-identifier hs-var" + >baz</span + ></a + ><span class="" + > </span + ><span class="hs-operator hs-var" + >.</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >sum</span + ><span class="" + > </span + ><span class="hs-operator hs-var" + >.</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >map</span + ><span class="" + > </span + ><a href="Classes.html#bar" + ><span class="hs-identifier hs-var" + >bar</span + ></a + ><span class="" + > + +</span + ><span class="hs-keyword" + >instance</span + ><span class="" + > </span + ><a href="Classes.html#Foo%27" + ><span class="hs-identifier hs-type" + >Foo'</span + ></a + ><span class="" + > </span + ><span class="hs-identifier hs-type" + >Int</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#norf" + ><span class="hs-identifier" + >norf</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >sum</span + ><span class="" + > + +</span + ><span class="hs-keyword" + >instance</span + ><span class="" + > </span + ><a href="Classes.html#Foo%27" + ><span class="hs-identifier hs-type" + >Foo'</span + ></a + ><span class="" + > </span + ><span class="hs-special" + >[</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >]</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#quux" + ><span class="hs-identifier" + >quux</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >uncurry</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-operator hs-var" + >++</span + ><span class="hs-special" + >)</span + ><span class="" + > + + +</span + ><span class="hs-keyword" + >class</span + ><span class="" + > </span + ><a name="Plugh" + ><a href="Classes.html#Plugh" + ><span class="hs-identifier" + >Plugh</span + ></a + ></a + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >p</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="plugh" + ><a href="Classes.html#plugh" + ><span class="hs-identifier" + >plugh</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >::</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >p</span + ></a + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >p</span + ></a + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >b</span + ></a + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >b</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >p</span + ></a + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >b</span + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >b</span + ></a + ><span class="" + > </span + ><span class="hs-glyph" + >-></span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-type" + >a</span + ></a + ><span class="hs-special" + >)</span + ><span class="" + > + +</span + ><span class="hs-keyword" + >instance</span + ><span class="" + > </span + ><a href="Classes.html#Plugh" + ><span class="hs-identifier hs-type" + >Plugh</span + ></a + ><span class="" + > </span + ><span class="hs-identifier hs-type" + >Either</span + ><span class="" + > </span + ><span class="hs-keyword" + >where</span + ><span class="" + > + </span + ><a name="local-0" + ><a href="Classes.html#plugh" + ><span class="hs-identifier" + >plugh</span + ></a + ></a + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-identifier hs-var" + >Left</span + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >a</span + ></a + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-identifier" + >_</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >Right</span + ><span class="" + > </span + ><span class="hs-operator hs-var" + >$</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >const</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >a</span + ></a + ><span class="" + > + </span + ><span class="hs-identifier" + >plugh</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-identifier hs-var" + >Right</span + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >a</span + ></a + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-identifier" + >_</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >Right</span + ><span class="" + > </span + ><span class="hs-operator hs-var" + >$</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >const</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >a</span + ></a + ><span class="" + > + </span + ><span class="hs-identifier" + >plugh</span + ><span class="" + > </span + ><span class="hs-identifier" + >_</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-identifier hs-var" + >Left</span + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >b</span + ></a + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >Left</span + ><span class="" + > </span + ><span class="hs-operator hs-var" + >$</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >const</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >b</span + ></a + ><span class="" + > + </span + ><span class="hs-identifier" + >plugh</span + ><span class="" + > </span + ><span class="hs-identifier" + >_</span + ><span class="" + > </span + ><span class="hs-special" + >(</span + ><span class="hs-identifier hs-var" + >Right</span + ><span class="" + > </span + ><a name="local-0" + ><a href="#local-0" + ><span class="hs-identifier" + >b</span + ></a + ></a + ><span class="hs-special" + >)</span + ><span class="" + > </span + ><span class="hs-glyph" + >=</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >Left</span + ><span class="" + > </span + ><span class="hs-operator hs-var" + >$</span + ><span class="" + > </span + ><span class="hs-identifier hs-var" + >const</span + ><span class="" + > </span + ><a href="#local-0" + ><span class="hs-identifier hs-var" + >b</span + ></a + ><span class="" + > +</span + ></pre + ></body + ></html +> diff --git a/hypsrc-test/src/Classes.hs b/hypsrc-test/src/Classes.hs new file mode 100644 index 00000000..bddb9939 --- /dev/null +++ b/hypsrc-test/src/Classes.hs @@ -0,0 +1,38 @@ +module Classes where + + +class Foo a where + bar :: a -> Int + baz :: Int -> (a, a) + +instance Foo Int where + bar = id + baz x = (x, x) + +instance Foo [a] where + bar = length + baz _ = ([], []) + + +class Foo a => Foo' a where + quux :: (a, a) -> a + quux (x, y) = norf [x, y] + + norf :: [a] -> a + norf = quux . baz . sum . map bar + +instance Foo' Int where + norf = sum + +instance Foo' [a] where + quux = uncurry (++) + + +class Plugh p where + plugh :: p a a -> p b b -> p (a -> b) (b -> a) + +instance Plugh Either where + plugh (Left a) _ = Right $ const a + plugh (Right a) _ = Right $ const a + plugh _ (Left b) = Left $ const b + plugh _ (Right b) = Left $ const b |