Last active
November 18, 2025 16:30
-
-
Save Garciat/274c42304ff1decd27eaaf6e2b6b3058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "31149831-c780-4394-bda7-aebd8edc2573", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "type Parser a = String -> Maybe (a, String)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 25, | |
| "id": "a636d5a3-197d-4508-ae8a-b264c31ee2ab", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "-- Primitive Parsers" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "295484ae-e27e-47ea-a944-8f193b07f6d5", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "satisfy :: (Char -> Bool) -> Parser Char\n", | |
| "satisfy p input =\n", | |
| " case input of\n", | |
| " (c:cs) | p c -> Just (c, cs)\n", | |
| " _ -> Nothing" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "id": "8e9a5ad7-7f40-49ab-a9db-06bbd7ca4678", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('a',\"bc\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "satisfy (\\c -> c == 'a') \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "id": "503db8e1-31d2-4c9e-94ba-25ec47e47242", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "char :: Char -> Parser Char\n", | |
| "char target = satisfy (\\c -> c == target)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "id": "cbd68e05-a052-4499-a885-f13a64aaafe7", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('a',\"bc\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "char 'a' \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "id": "c4fae55d-3361-4f3c-b11d-782d4a1f6292", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Nothing" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "char 'z' \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 17, | |
| "id": "2fc86e5b-13c1-49c7-bcd8-f304e45f7f53", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Nothing" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "char 'z' []" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 18, | |
| "id": "15ec6c28-f9cf-4f4c-9e55-4d33398a45c1", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import Data.Char" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 19, | |
| "id": "d7c4e1da-6634-466a-8c7f-0f71c1f82329", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>isDigit :: Char -> Bool</span>" | |
| ], | |
| "text/plain": [ | |
| "isDigit :: Char -> Bool" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t isDigit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 20, | |
| "id": "96f209bf-6958-4f13-9671-92a8a4b0bf2b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "digit :: Parser Char\n", | |
| "digit = satisfy isDigit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 23, | |
| "id": "c8611ab0-fe40-42db-bb9a-627fc7ad00a9", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('1',\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "digit \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 22, | |
| "id": "8584861f-b3b4-470d-bb1a-7d3d2604a59a", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Nothing" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "digit \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 112, | |
| "id": "554147bd-ccc9-49db-b2a9-a9d73f93cf39", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "-- type String = [Char]\n", | |
| "\n", | |
| "string :: String -> Parser String\n", | |
| "string s = sequence (map char s)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 113, | |
| "id": "f83383ba-0114-4b18-bcd1-63da76e4d3e5", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>string \"123\" :: Parser String</span>" | |
| ], | |
| "text/plain": [ | |
| "string \"123\" :: Parser String" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t string \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 117, | |
| "id": "8b877b63-0f31-468c-86ce-5d0b928652c7", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"123\",\"xyz\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "string \"123\" \"123xyz\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 109, | |
| "id": "ba66713f-31cd-4d8c-8c7f-e0b0db9d0814", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>map :: forall a b. (a -> b) -> [a] -> [b]</span>" | |
| ], | |
| "text/plain": [ | |
| "map :: forall a b. (a -> b) -> [a] -> [b]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t map" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 110, | |
| "id": "da64377e-463c-4156-935f-c09d830781ac", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>map char :: [Char] -> [Parser Char]</span>" | |
| ], | |
| "text/plain": [ | |
| "map char :: [Char] -> [Parser Char]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t map char" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 108, | |
| "id": "c9b85bc0-c478-4424-949f-095a87609411", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>map char \"123\" :: [Parser Char]</span>" | |
| ], | |
| "text/plain": [ | |
| "map char \"123\" :: [Parser Char]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t map char \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 111, | |
| "id": "eff304d6-3275-4b5b-a158-c18fc82e41c0", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>sequence (map char \"123\") :: Parser [Char]</span>" | |
| ], | |
| "text/plain": [ | |
| "sequence (map char \"123\") :: Parser [Char]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t sequence (map char \"123\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 24, | |
| "id": "da1539fc-d407-47b4-b40b-fcc0c8d1c753", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "-- Parser Combinators" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 51, | |
| "id": "8981bf60-4955-44b1-8715-1b06c04bc3e1", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "parserMap :: (a -> b) -> Parser a -> Parser b\n", | |
| "parserMap f pa input =\n", | |
| " case pa input of\n", | |
| " Nothing -> Nothing\n", | |
| " Just (a, input') -> Just (f a, input')\n", | |
| "\n", | |
| "(<$>) = parserMap" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 28, | |
| "id": "d290fe0a-7bf8-4aa4-afe4-732aefb21133", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>digitToInt :: Char -> Int</span>" | |
| ], | |
| "text/plain": [ | |
| "digitToInt :: Char -> Int" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t digitToInt" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 29, | |
| "id": "d27e5550-04b8-437f-8dfe-f559b5896cee", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "5" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "digitToInt '5'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 32, | |
| "id": "8e9d98cb-de98-42c7-937c-21264e0d835c", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>parserMap digitToInt digit :: Parser Int</span>" | |
| ], | |
| "text/plain": [ | |
| "parserMap digitToInt digit :: Parser Int" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t parserMap digitToInt digit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 35, | |
| "id": "89f33349-50e7-4d2e-aac2-5ba5292cc913", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (1,\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "parserMap digitToInt digit \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 53, | |
| "id": "3400d38a-01f1-46a9-9b85-d715144d4f96", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (1,\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(digitToInt <$> digit) \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 54, | |
| "id": "73f1f42c-47d9-44ad-94af-08b755e60cdf", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "123" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "id 123" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 55, | |
| "id": "02b74b20-be50-4498-8b09-58ffda0cd34b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "123" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "id $ 123" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 57, | |
| "id": "7f0148ca-e612-421d-a6d1-f729f76dd3dd", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "123" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "id (id (id 123))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 60, | |
| "id": "6371d9e0-362c-4113-8afe-6d58614897b5", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "123" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "id $ id $ id $ 123" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 61, | |
| "id": "f6a9fac4-0164-4174-a8e0-ac07e173017c", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>($) :: forall a b. (a -> b) -> a -> b</span>" | |
| ], | |
| "text/plain": [ | |
| "($) :: forall a b. (a -> b) -> a -> b" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t ($)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 62, | |
| "id": "3b92bb13-1179-4308-9248-21f3346f81bf", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>(<$>) :: forall {a} {b}. (a -> b) -> Parser a -> Parser b</span>" | |
| ], | |
| "text/plain": [ | |
| "(<$>) :: forall {a} {b}. (a -> b) -> Parser a -> Parser b" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t (<$>)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 47, | |
| "id": "c02bd6de-ab3c-4b50-9698-71d8f732ffb6", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "-- RegExp: (a|b)\n", | |
| "alt :: Parser a -> Parser a -> Parser a\n", | |
| "alt p1 p2 input =\n", | |
| " case p1 input of\n", | |
| " Just (a, remainder) -> Just (a, remainder)\n", | |
| " Nothing -> p2 input\n", | |
| "\n", | |
| "(<|>) = alt" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 37, | |
| "id": "34292e72-2bed-455c-8280-6649901bd82b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>alt (char 'a') (char 'b') :: Parser Char</span>" | |
| ], | |
| "text/plain": [ | |
| "alt (char 'a') (char 'b') :: Parser Char" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t alt (char 'a') (char 'b')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 48, | |
| "id": "41a9c918-7186-409a-b201-9a78c5370108", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('a',\"bc\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(char 'a' <|> char 'b') \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 50, | |
| "id": "11dcd69b-16ad-4f07-8705-65b0200adc70", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "fail :: Parser a\n", | |
| "fail input = Nothing" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 63, | |
| "id": "535aa9fc-607d-4e6f-88b7-38a7b1832254", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "value :: a -> Parser a\n", | |
| "value a input = Just (a, input)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 64, | |
| "id": "107df46b-20a5-4e25-aefe-b96852db2baf", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (123,\"abc\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "value 123 \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 65, | |
| "id": "be84773d-06dd-4606-a427-5e7601ec9a75", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('a',\"bc\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(char 'a' <|> value 'z') \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 68, | |
| "id": "c57e3131-e0af-4cdb-b5cd-7c375ea7a9d9", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('z',\"xyz\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(char 'a' <|> value 'z') \"xyz\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 125, | |
| "id": "0ea23e69-0228-46ea-8e56-7b0737519fae", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "app :: Parser (a -> b) -> Parser a -> Parser b\n", | |
| "app pf pa input =\n", | |
| " case pf input of\n", | |
| " Just (f, input') ->\n", | |
| " case pa input' of\n", | |
| " Just (a, input'') -> Just (f a, input'')\n", | |
| " Nothing -> Nothing\n", | |
| " Nothing -> Nothing\n", | |
| "\n", | |
| "(<*>) = app\n", | |
| "\n", | |
| "(*>) :: Parser b -> Parser a -> Parser a\n", | |
| "pb *> pa = (\\b a -> a) <$> pb <*> pa\n", | |
| "\n", | |
| "\n", | |
| "(<*) :: Parser a -> Parser b -> Parser a\n", | |
| "pa <* pb = (\\a b -> a) <$> pa <*> pb" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 124, | |
| "id": "70361744-d646-4561-a44a-546744d0589f", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('1',\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(char 'a' *> digit) \"a123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 126, | |
| "id": "07aa6e26-dca2-4dc8-bf88-8054ed7beb91", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just ('a',\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(char 'a' <* digit) \"a123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 84, | |
| "id": "a7a19329-0bc0-4adc-9226-70633e7a1300", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "add :: Int -> Int -> Int\n", | |
| "add x y = x + y" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 72, | |
| "id": "f6112466-101b-4e81-94c3-af68aaacf31e", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "14" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "add 10 4" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 73, | |
| "id": "a1e692ed-8ed1-405c-b07d-295be3183373", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "digitI :: Parser Int\n", | |
| "digitI = digitToInt <$> digit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 74, | |
| "id": "7240accf-e52b-4885-a189-236ca62afe2b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (1,\"23\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "digitI \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 75, | |
| "id": "8ea175ee-b893-41c3-8109-b11b47145e8b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>negate :: forall a. Num a => a -> a</span>" | |
| ], | |
| "text/plain": [ | |
| "negate :: forall a. Num a => a -> a" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t negate" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 76, | |
| "id": "5072d42a-7773-4eae-bec3-a9d9abfd86ea", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "-10" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "negate 10" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 77, | |
| "id": "32d57498-4e6d-4d18-9386-275123ed6b1f", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "10" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "negate (-10)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 81, | |
| "id": "49a99a9d-91ce-4f51-93ea-032c7a4777d6", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>digitI :: Parser Int</span>" | |
| ], | |
| "text/plain": [ | |
| "digitI :: Parser Int" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t digitI" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 82, | |
| "id": "b9989bf9-12ba-4f97-a726-41df4cd4ef56", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>(<$>) :: forall {a} {b}. (a -> b) -> Parser a -> Parser b</span>" | |
| ], | |
| "text/plain": [ | |
| "(<$>) :: forall {a} {b}. (a -> b) -> Parser a -> Parser b" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t (<$>)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 83, | |
| "id": "939e0bfb-9a30-48ba-8186-a891b4c5f3ff", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>negate <$> digitI :: Parser Int</span>" | |
| ], | |
| "text/plain": [ | |
| "negate <$> digitI :: Parser Int" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t negate <$> digitI" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 88, | |
| "id": "5796fd2d-981f-4076-820a-1c640217f079", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>add <$> digitI <*> digitI :: Parser Int</span>" | |
| ], | |
| "text/plain": [ | |
| "add <$> digitI <*> digitI :: Parser Int" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t add <$> digitI <*> digitI" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 90, | |
| "id": "3a5fb3e5-9c07-4abb-9480-14cf6047d82f", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (4,\"9\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(add <$> digitI <*> digitI) \"139\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 93, | |
| "id": "55c788b0-588f-4c1f-a989-c0f19aaa4839", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "mathStuff x y z = x * y + z * 10" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 94, | |
| "id": "066a486a-894a-48d6-b01b-2d9741139529", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (93,\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(mathStuff <$> digitI <*> digitI <*> digitI) \"139\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 104, | |
| "id": "c59a1e5a-380e-400d-a604-9e1e976c1ff3", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "sequence :: [Parser a] -> Parser [a]\n", | |
| "sequence [] = value []\n", | |
| "sequence (p:ps) = (:) <$> p <*> sequence ps" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 105, | |
| "id": "0007ffb3-048e-45a0-af32-1a493c82909a", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"ab\",\"c\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "sequence [char 'a', char 'b'] \"abc\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 97, | |
| "id": "e1b714b6-79ff-41e4-89cb-a99b3f74449a", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>(:) :: forall a. a -> [a] -> [a]</span>" | |
| ], | |
| "text/plain": [ | |
| "(:) :: forall a. a -> [a] -> [a]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t (:)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 98, | |
| "id": "90b8cb9c-1328-47d5-82a1-8728f742822c", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "[1,2,3,4]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "1:[2,3,4]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 99, | |
| "id": "25426e4f-3abb-4cd2-ab10-c67b859b1b6b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "[1,2,3,4]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "1:2:3:4:[]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 100, | |
| "id": "c7d436f3-2bbd-4e4e-94d6-8ca9a95d6977", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>[] :: forall a. [a]</span>" | |
| ], | |
| "text/plain": [ | |
| "[] :: forall a. [a]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t []" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 101, | |
| "id": "46bbc0b3-7e23-4589-94aa-6b82a426e5b4", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "8" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(+) 3 5" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 102, | |
| "id": "413aa0ba-2089-431f-872b-6b84186baa9b", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "8" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "3 + 5" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 134, | |
| "id": "70d1687f-10c5-4fb8-9077-eabbae4de6ce", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "-- RegExp: a*\n", | |
| "many :: Parser a -> Parser [a]\n", | |
| "many pa = many1 pa <|> value []\n", | |
| "\n", | |
| "-- RegExp: a+\n", | |
| "many1 :: Parser a -> Parser [a]\n", | |
| "many1 pa = (:) <$> pa <*> many pa" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 136, | |
| "id": "e4f4d6b5-0ff3-4dbb-bec4-97c0ded2f959", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"\",\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "many digit \"\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 137, | |
| "id": "0f742ab7-e64a-4fe2-844c-06d5bd4a42a5", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Nothing" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "many1 digit \"\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 138, | |
| "id": "cf7d86b9-98e4-46fe-a745-8b0ea6e80dff", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"123\",\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "many1 digit \"123\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 160, | |
| "id": "cb0b3208-c9dd-453a-bce7-f7b37fc8ecc8", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "sepBy :: Parser a -> Parser b -> Parser [a]\n", | |
| "sepBy pa sep = sepBy1 pa sep <|> value []\n", | |
| "\n", | |
| "sepBy1 :: Parser a -> Parser b -> Parser [a]\n", | |
| "sepBy1 pa sep = (:) <$> pa <*> many (sep *> pa)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 163, | |
| "id": "92a4efb6-4a05-4cf4-a726-f2384d334a85", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"123\",\",\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "(digit `sepBy` char ',') \"1,2,3,\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 140, | |
| "id": "2c0ae2fd-740c-44f8-9f2a-23d1efbd5974", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "data JSON\n", | |
| " = JNull\n", | |
| " | JNumber String\n", | |
| " | JString String\n", | |
| " | JBool Bool\n", | |
| " | JArray [JSON]\n", | |
| " | JObject [(String, JSON)]\n", | |
| " deriving Show" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 141, | |
| "id": "53537abf-bf3c-4a28-b30b-f99da748539d", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "jnull :: Parser JSON\n", | |
| "jnull = string \"null\" *> value JNull" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 133, | |
| "id": "bf3bb4cc-c019-4ddc-b8ca-d8ef3b3d45c6", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JNull,\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "jnull \"null\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 142, | |
| "id": "8fc35e5c-b87a-4ae9-bccd-835d4ab74768", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "jnumber :: Parser JSON\n", | |
| "jnumber = JNumber <$> many1 digit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 144, | |
| "id": "bf388ac6-d39c-451c-8f3e-041eb3d1b619", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>digit :: Parser Char</span>" | |
| ], | |
| "text/plain": [ | |
| "digit :: Parser Char" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t digit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 145, | |
| "id": "0e140e37-26df-44ce-8127-dc8ce41cf8d7", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>many1 :: forall a. Parser a -> Parser [a]</span>" | |
| ], | |
| "text/plain": [ | |
| "many1 :: forall a. Parser a -> Parser [a]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t many1" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 143, | |
| "id": "4c20d811-0e5d-4f94-9371-3f03c632554c", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>many1 digit :: Parser [Char]</span>" | |
| ], | |
| "text/plain": [ | |
| "many1 digit :: Parser [Char]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t many1 digit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 146, | |
| "id": "85172cb3-79c0-4a34-82a2-c93830be9275", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>JNumber :: String -> JSON</span>" | |
| ], | |
| "text/plain": [ | |
| "JNumber :: String -> JSON" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t JNumber" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 147, | |
| "id": "8c383277-e070-4036-aad6-852713c66962", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "stringLit :: Parser String\n", | |
| "stringLit = char '\"' *> (many (satisfy (\\c -> c /= '\"'))) <* char '\"'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 152, | |
| "id": "5590a1c6-bf09-44dc-a623-0f2596542a70", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (\"123\",\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "stringLit \"\\\"123\\\"\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 153, | |
| "id": "d37f64d1-9f79-4a0c-b6a2-3f3f6ec97293", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "jstring :: Parser JSON\n", | |
| "jstring = JString <$> stringLit" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 154, | |
| "id": "7e59207b-3e41-48df-b6fc-f6bb19380c4d", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "jbool :: Parser JSON\n", | |
| "jbool = jtrue <|> jfalse\n", | |
| " where\n", | |
| " jtrue = string \"true\" *> value (JBool True)\n", | |
| " jfalse = string \"false\" *> value (JBool False)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 155, | |
| "id": "ca4d6b41-9bf4-4367-a12f-380850394985", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JBool True,\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "jbool \"true\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 156, | |
| "id": "5f8e751e-f7b2-4316-b9ec-404e7c1ad021", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>JBool :: Bool -> JSON</span>" | |
| ], | |
| "text/plain": [ | |
| "JBool :: Bool -> JSON" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t JBool" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 158, | |
| "id": "3258647f-d5e4-449c-8ba5-3ed2668b181a", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>JBool True :: JSON</span>" | |
| ], | |
| "text/plain": [ | |
| "JBool True :: JSON" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t JBool True" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 159, | |
| "id": "16fd7f49-74e8-42f4-8bde-dae19b607095", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JBool False,\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "jbool \"false\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 189, | |
| "id": "7bd74060-901e-42b6-9d39-ee553486f02a", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "json :: Parser JSON\n", | |
| "json = jnull <|> jnumber <|> jstring <|> jbool <|> jarray <|> jobject\n", | |
| "\n", | |
| "jarray :: Parser JSON\n", | |
| "jarray = char '[' *> contents <* char ']'\n", | |
| " where\n", | |
| " contents = JArray <$> (json `sepBy` char ',')\n", | |
| " \n", | |
| "jobject :: Parser JSON\n", | |
| "jobject = char '{' *> contents <* char '}'\n", | |
| " where\n", | |
| " contents = JObject <$> (prop `sepBy` char ',')\n", | |
| " \n", | |
| " prop :: Parser (String, JSON)\n", | |
| " prop = (,) <$> propKey <*> json\n", | |
| " \n", | |
| " propKey :: Parser String\n", | |
| " propKey = stringLit <* char ':'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 176, | |
| "id": "6ba0f6b0-f5b6-4242-94b8-a37f75a1cd03", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JArray [JNumber \"1\",JNumber \"2\",JNumber \"3\"],\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "json \"[1,2,3]\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 177, | |
| "id": "ef5633ae-235f-4ec7-9243-2e48f0da2872", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JArray [JArray [JNumber \"1\",JNumber \"2\",JNumber \"3\"],JArray [JNumber \"4\",JNumber \"5\",JNumber \"6\"],JArray [JNumber \"7\",JNumber \"8\",JNumber \"9\"]],\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "json \"[[1,2,3],[4,5,6],[7,8,9]]\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 184, | |
| "id": "f4b07865-7790-4560-8993-d2b707c255eb", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JArray [JNull,JNumber \"1\",JBool True,JBool False,JArray [],JObject []],\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "json \"[null,1,true,false,[],{}]\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 182, | |
| "id": "754dd7db-613f-4e01-bdf6-f84ea1f1a36c", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "Just (JObject [(\"x\",JArray [JNumber \"1\",JNumber \"2\",JNumber \"3\"]),(\"y\",JArray [JNull,JBool False,JArray [JNumber \"1\",JNumber \"2\",JNumber \"3\"]])],\"\")" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "json \"{\\\"x\\\":[1,2,3],\\\"y\\\":[null,false,[1,2,3]]}\"" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 167, | |
| "id": "109ecb89-89b7-4a83-9959-b081d73172ce", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>('a','b') :: (Char, Char)</span>" | |
| ], | |
| "text/plain": [ | |
| "('a','b') :: (Char, Char)" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t ('a','b')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 169, | |
| "id": "d6ff3fb4-59d5-4fa6-b71d-289fd37a9832", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>('a', ) 'b' :: (Char, Char)</span>" | |
| ], | |
| "text/plain": [ | |
| "('a', ) 'b' :: (Char, Char)" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t ('a', ) 'b'" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 170, | |
| "id": "80ff99a3-2544-4a4f-b8f3-ee4f9f0597ef", | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "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", | |
| "\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", | |
| "\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\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", | |
| "\n", | |
| "</style><span class='get-type'>(,) 'a' 'b' :: (Char, Char)</span>" | |
| ], | |
| "text/plain": [ | |
| "(,) 'a' 'b' :: (Char, Char)" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t (,) 'a' 'b'" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Haskell", | |
| "language": "haskell", | |
| "name": "haskell" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": "ihaskell", | |
| "file_extension": ".hs", | |
| "mimetype": "text/x-haskell", | |
| "name": "haskell", | |
| "pygments_lexer": "Haskell", | |
| "version": "9.6.4" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment