X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=src%2Fadvent12%2Fadvent12.ipynb;fp=src%2Fadvent12%2Fadvent12.ipynb;h=4b8527312fef61040986b26393a8db34f276c301;hb=eaa734f5c98fa8f194a70b6e3b188710c34c3dac;hp=0000000000000000000000000000000000000000;hpb=f74ed68a4c7b0349383c7f36da591ba8feac6de6;p=advent-of-code-17.git
diff --git a/src/advent12/advent12.ipynb b/src/advent12/advent12.ipynb
new file mode 100644
index 0000000..4b85273
--- /dev/null
+++ b/src/advent12/advent12.ipynb
@@ -0,0 +1,204 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "{-# LANGUAGE NegativeLiterals #-}\n",
+ "{-# LANGUAGE FlexibleContexts #-}\n",
+ "{-# LANGUAGE OverloadedStrings #-}"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import Data.Text (Text)\n",
+ "import qualified Data.Text as T\n",
+ "import qualified Data.Text.IO as TIO\n",
+ "\n",
+ "import Text.Megaparsec\n",
+ "import qualified Text.Megaparsec.Lexer as L\n",
+ "-- import Text.Megaparsec.Lexer\n",
+ "import Text.Megaparsec.Text (Parser)\n",
+ "\n",
+ "import qualified Data.IntMap.Strict as M\n",
+ "import Data.IntMap.Strict ((!))\n",
+ "\n",
+ "import qualified Data.Set as S"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "type Pipes = M.IntMap (S.Set Int)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "<interactive>:5:5: error:
⢠Illegal equational constraint Token s ~ Char
(Use GADTs or TypeFamilies to permit this)
⢠When checking the inferred type
blockCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()
In an equation for âscâ:
sc
= L.space space lineCmnt blockCmnt
where
lineCmnt = L.skipLineComment \"//\"
blockCmnt = L.skipBlockComment \"/*\" \"*/\"
<interactive>:4:5: error:
⢠Illegal equational constraint Token s ~ Char
(Use GADTs or TypeFamilies to permit this)
⢠When checking the inferred type
lineCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()
In an equation for âscâ:
sc
= L.space space lineCmnt blockCmnt
where
lineCmnt = L.skipLineComment \"//\"
blockCmnt = L.skipBlockComment \"/*\" \"*/\""
+ ],
+ "text/plain": [
+ ":5:5: error:\n",
+ " ⢠Illegal equational constraint Token s ~ Char\n",
+ " (Use GADTs or TypeFamilies to permit this)\n",
+ " ⢠When checking the inferred type\n",
+ " blockCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()\n",
+ " In an equation for âscâ:\n",
+ " sc\n",
+ " = L.space space lineCmnt blockCmnt\n",
+ " where\n",
+ " lineCmnt = L.skipLineComment \"//\"\n",
+ " blockCmnt = L.skipBlockComment \"/*\" \"*/\"\n",
+ ":4:5: error:\n",
+ " ⢠Illegal equational constraint Token s ~ Char\n",
+ " (Use GADTs or TypeFamilies to permit this)\n",
+ " ⢠When checking the inferred type\n",
+ " lineCmnt :: forall e s (m :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => m ()\n",
+ " In an equation for âscâ:\n",
+ " sc\n",
+ " = L.space space lineCmnt blockCmnt\n",
+ " where\n",
+ " lineCmnt = L.skipLineComment \"//\"\n",
+ " blockCmnt = L.skipBlockComment \"/*\" \"*/\""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "sc :: Parser ()\n",
+ "sc = L.space space lineCmnt blockCmnt\n",
+ " where\n",
+ " lineCmnt = L.skipLineComment \"//\"\n",
+ " blockCmnt = L.skipBlockComment \"/*\" \"*/\"\n",
+ "\n",
+ "lexeme = L.lexeme sc\n",
+ "integer = lexeme L.integer\n",
+ "\n",
+ "symb = L.symbol sc\n",
+ "\n",
+ "\n",
+ "pipe = assocify <$> integer <*> (symb \"<->\" *> (integer `sepBy` (symb \",\")))\n",
+ " where assocify a b = (a, b)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Haskell",
+ "language": "haskell",
+ "name": "haskell"
+ },
+ "language_info": {
+ "codemirror_mode": "ihaskell",
+ "file_extension": ".hs",
+ "name": "haskell",
+ "version": "8.0.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}