Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
<!doctype html>
2
<title>CodeMirror: Haskell mode</title>
3
<meta charset="utf-8" />
4
<link rel=stylesheet href="../../doc/docs.css">
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<link rel="stylesheet" href="../../theme/elegant.css">
7
<script src="../../lib/codemirror.js"></script>
8
<script src="../../addon/edit/matchbrackets.js"></script>
9
<script src="haskell.js"></script>
10
<style type="text/css">
11
    .CodeMirror {
12
        border-top: 1px solid black;
13
        border-bottom: 1px solid black;
14
    }
15
</style>
16
<div id=nav>
17
    <a href="http://codemirror.net">
18
        <h1>CodeMirror</h1>
19
        <img id=logo src="../../doc/logo.png">
20
    </a>
21
    <ul>
22
        <li>
23
            <a href="../../index.html">Home</a>
24
            <li>
25
                <a href="../../doc/manual.html">Manual</a>
26
                <li>
27
                    <a href="https://github.com/codemirror/codemirror">Code</a>
28
    </ul>
29
    <ul>
30
        <li>
31
            <a href="../index.html">Language modes</a>
32
            <li>
33
                <a class=active href="#">Haskell</a>
34
    </ul>
35
</div>
36
<article>
37
    <h2>Haskell mode</h2>
38
    <form>
39
        <textarea id="code" name="code"> module UniquePerms ( uniquePerms ) where -- | Find all unique permutations of a list where there might be duplicates. uniquePerms :: (Eq a) => [a] -> [[a]] uniquePerms = permBag . makeBag -- | An unordered collection where duplicate values are
40
            allowed, -- but represented with a single value and a count. type Bag a = [(a, Int)] makeBag :: (Eq a) => [a] -> Bag a makeBag [] = [] makeBag (a:as) = mix a $ makeBag as where mix a [] = [(a,1)] mix a (bn@(b,n):bs) | a == b = (b,n+1):bs |
41
            otherwise = bn : mix a bs permBag :: Bag a -> [[a]] permBag [] = [[]] permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs where oneOfEach [] = [] oneOfEach (an@(a,n):bs) = let bs' = if n == 1 then bs else (a,n-1):bs
42
            in (a,bs') : mapSnd (an:) (oneOfEach bs) apSnd f (a,b) = (a, f b) mapSnd = map . apSnd </textarea>
43
    </form>
44
    <script>
45
        var editor = CodeMirror.fromTextArea(document.getElementById("code"),
46
        {
47
            lineNumbers: true,
48
            matchBrackets: true,
49
            theme: "elegant"
50
        });
51
    </script>
52
    <p>
53
        <strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
54
</article>