--- /dev/null
+{
+ "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": [
+ "<style>/* Styles used for the Hoogle display in the pager */\n",
+ ".hoogle-doc {\n",
+ "display: block;\n",
+ "padding-bottom: 1.3em;\n",
+ "padding-left: 0.4em;\n",
+ "}\n",
+ ".hoogle-code {\n",
+ "display: block;\n",
+ "font-family: monospace;\n",
+ "white-space: pre;\n",
+ "}\n",
+ ".hoogle-text {\n",
+ "display: block;\n",
+ "}\n",
+ ".hoogle-name {\n",
+ "color: green;\n",
+ "font-weight: bold;\n",
+ "}\n",
+ ".hoogle-head {\n",
+ "font-weight: bold;\n",
+ "}\n",
+ ".hoogle-sub {\n",
+ "display: block;\n",
+ "margin-left: 0.4em;\n",
+ "}\n",
+ ".hoogle-package {\n",
+ "font-weight: bold;\n",
+ "font-style: italic;\n",
+ "}\n",
+ ".hoogle-module {\n",
+ "font-weight: bold;\n",
+ "}\n",
+ ".hoogle-class {\n",
+ "font-weight: bold;\n",
+ "}\n",
+ ".get-type {\n",
+ "color: green;\n",
+ "font-weight: bold;\n",
+ "font-family: monospace;\n",
+ "display: block;\n",
+ "white-space: pre-wrap;\n",
+ "}\n",
+ ".show-type {\n",
+ "color: green;\n",
+ "font-weight: bold;\n",
+ "font-family: monospace;\n",
+ "margin-left: 1em;\n",
+ "}\n",
+ ".mono {\n",
+ "font-family: monospace;\n",
+ "display: block;\n",
+ "}\n",
+ ".err-msg {\n",
+ "color: red;\n",
+ "font-style: italic;\n",
+ "font-family: monospace;\n",
+ "white-space: pre;\n",
+ "display: block;\n",
+ "}\n",
+ "#unshowable {\n",
+ "color: red;\n",
+ "font-weight: bold;\n",
+ "}\n",
+ ".err-msg.in.collapse {\n",
+ "padding-top: 0.7em;\n",
+ "}\n",
+ ".highlight-code {\n",
+ "white-space: pre;\n",
+ "font-family: monospace;\n",
+ "}\n",
+ ".suggestion-warning { \n",
+ "font-weight: bold;\n",
+ "color: rgb(200, 130, 0);\n",
+ "}\n",
+ ".suggestion-error { \n",
+ "font-weight: bold;\n",
+ "color: red;\n",
+ "}\n",
+ ".suggestion-name {\n",
+ "font-weight: bold;\n",
+ "}\n",
+ "</style><span class='err-msg'><interactive>: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 :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => 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/><interactive>: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 :: * -> *). (Token s ~ Char, Text.Megaparsec.Prim.MonadParsec e s m) => 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>"
+ ],
+ "text/plain": [
+ "<interactive>: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",
+ "<interactive>: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
+}