{
"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
}