Done day 12
[advent-of-code-17.git] / src / advent12 / advent12.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {},
7 "outputs": [],
8 "source": [
9 "{-# LANGUAGE NegativeLiterals #-}\n",
10 "{-# LANGUAGE FlexibleContexts #-}\n",
11 "{-# LANGUAGE OverloadedStrings #-}"
12 ]
13 },
14 {
15 "cell_type": "code",
16 "execution_count": 6,
17 "metadata": {},
18 "outputs": [],
19 "source": [
20 "import Data.Text (Text)\n",
21 "import qualified Data.Text as T\n",
22 "import qualified Data.Text.IO as TIO\n",
23 "\n",
24 "import Text.Megaparsec\n",
25 "import qualified Text.Megaparsec.Lexer as L\n",
26 "-- import Text.Megaparsec.Lexer\n",
27 "import Text.Megaparsec.Text (Parser)\n",
28 "\n",
29 "import qualified Data.IntMap.Strict as M\n",
30 "import Data.IntMap.Strict ((!))\n",
31 "\n",
32 "import qualified Data.Set as S"
33 ]
34 },
35 {
36 "cell_type": "code",
37 "execution_count": 7,
38 "metadata": {},
39 "outputs": [],
40 "source": [
41 "type Pipes = M.IntMap (S.Set Int)"
42 ]
43 },
44 {
45 "cell_type": "code",
46 "execution_count": 21,
47 "metadata": {},
48 "outputs": [
49 {
50 "data": {
51 "text/html": [
52 "<style>/* Styles used for the Hoogle display in the pager */\n",
53 ".hoogle-doc {\n",
54 "display: block;\n",
55 "padding-bottom: 1.3em;\n",
56 "padding-left: 0.4em;\n",
57 "}\n",
58 ".hoogle-code {\n",
59 "display: block;\n",
60 "font-family: monospace;\n",
61 "white-space: pre;\n",
62 "}\n",
63 ".hoogle-text {\n",
64 "display: block;\n",
65 "}\n",
66 ".hoogle-name {\n",
67 "color: green;\n",
68 "font-weight: bold;\n",
69 "}\n",
70 ".hoogle-head {\n",
71 "font-weight: bold;\n",
72 "}\n",
73 ".hoogle-sub {\n",
74 "display: block;\n",
75 "margin-left: 0.4em;\n",
76 "}\n",
77 ".hoogle-package {\n",
78 "font-weight: bold;\n",
79 "font-style: italic;\n",
80 "}\n",
81 ".hoogle-module {\n",
82 "font-weight: bold;\n",
83 "}\n",
84 ".hoogle-class {\n",
85 "font-weight: bold;\n",
86 "}\n",
87 ".get-type {\n",
88 "color: green;\n",
89 "font-weight: bold;\n",
90 "font-family: monospace;\n",
91 "display: block;\n",
92 "white-space: pre-wrap;\n",
93 "}\n",
94 ".show-type {\n",
95 "color: green;\n",
96 "font-weight: bold;\n",
97 "font-family: monospace;\n",
98 "margin-left: 1em;\n",
99 "}\n",
100 ".mono {\n",
101 "font-family: monospace;\n",
102 "display: block;\n",
103 "}\n",
104 ".err-msg {\n",
105 "color: red;\n",
106 "font-style: italic;\n",
107 "font-family: monospace;\n",
108 "white-space: pre;\n",
109 "display: block;\n",
110 "}\n",
111 "#unshowable {\n",
112 "color: red;\n",
113 "font-weight: bold;\n",
114 "}\n",
115 ".err-msg.in.collapse {\n",
116 "padding-top: 0.7em;\n",
117 "}\n",
118 ".highlight-code {\n",
119 "white-space: pre;\n",
120 "font-family: monospace;\n",
121 "}\n",
122 ".suggestion-warning { \n",
123 "font-weight: bold;\n",
124 "color: rgb(200, 130, 0);\n",
125 "}\n",
126 ".suggestion-error { \n",
127 "font-weight: bold;\n",
128 "color: red;\n",
129 "}\n",
130 ".suggestion-name {\n",
131 "font-weight: bold;\n",
132 "}\n",
133 "</style><span class='err-msg'>&lt;interactive&gt;:5:5: error:<br/> • Illegal equational constraint Token s ~ Char<br/> (Use GADTs or TypeFamilies to permit this)<br/> • When checking the inferred type<br/> blockCmnt :: forall e s (m :: * -&gt; *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) =&gt; m ()<br/> In an equation for ‘sc’:<br/> sc<br/> = L.space space lineCmnt blockCmnt<br/> where<br/> lineCmnt = L.skipLineComment \"//\"<br/> blockCmnt = L.skipBlockComment \"/*\" \"*/\"<br/>&lt;interactive&gt;:4:5: error:<br/> • Illegal equational constraint Token s ~ Char<br/> (Use GADTs or TypeFamilies to permit this)<br/> • When checking the inferred type<br/> lineCmnt :: forall e s (m :: * -&gt; *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) =&gt; m ()<br/> In an equation for ‘sc’:<br/> sc<br/> = L.space space lineCmnt blockCmnt<br/> where<br/> lineCmnt = L.skipLineComment \"//\"<br/> blockCmnt = L.skipBlockComment \"/*\" \"*/\"</span>"
134 ],
135 "text/plain": [
136 "<interactive>:5:5: error:\n",
137 " • Illegal equational constraint Token s ~ Char\n",
138 " (Use GADTs or TypeFamilies to permit this)\n",
139 " • When checking the inferred type\n",
140 " blockCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()\n",
141 " In an equation for ‘sc’:\n",
142 " sc\n",
143 " = L.space space lineCmnt blockCmnt\n",
144 " where\n",
145 " lineCmnt = L.skipLineComment \"//\"\n",
146 " blockCmnt = L.skipBlockComment \"/*\" \"*/\"\n",
147 "<interactive>:4:5: error:\n",
148 " • Illegal equational constraint Token s ~ Char\n",
149 " (Use GADTs or TypeFamilies to permit this)\n",
150 " • When checking the inferred type\n",
151 " lineCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()\n",
152 " In an equation for ‘sc’:\n",
153 " sc\n",
154 " = L.space space lineCmnt blockCmnt\n",
155 " where\n",
156 " lineCmnt = L.skipLineComment \"//\"\n",
157 " blockCmnt = L.skipBlockComment \"/*\" \"*/\""
158 ]
159 },
160 "metadata": {},
161 "output_type": "display_data"
162 }
163 ],
164 "source": [
165 "sc :: Parser ()\n",
166 "sc = L.space space lineCmnt blockCmnt\n",
167 " where\n",
168 " lineCmnt = L.skipLineComment \"//\"\n",
169 " blockCmnt = L.skipBlockComment \"/*\" \"*/\"\n",
170 "\n",
171 "lexeme = L.lexeme sc\n",
172 "integer = lexeme L.integer\n",
173 "\n",
174 "symb = L.symbol sc\n",
175 "\n",
176 "\n",
177 "pipe = assocify <$> integer <*> (symb \"<->\" *> (integer `sepBy` (symb \",\")))\n",
178 " where assocify a b = (a, b)\n"
179 ]
180 },
181 {
182 "cell_type": "code",
183 "execution_count": null,
184 "metadata": {},
185 "outputs": [],
186 "source": []
187 }
188 ],
189 "metadata": {
190 "kernelspec": {
191 "display_name": "Haskell",
192 "language": "haskell",
193 "name": "haskell"
194 },
195 "language_info": {
196 "codemirror_mode": "ihaskell",
197 "file_extension": ".hs",
198 "name": "haskell",
199 "version": "8.0.2"
200 }
201 },
202 "nbformat": 4,
203 "nbformat_minor": 2
204 }