Last active
June 1, 2017 19:12
-
-
Save furu/f8880f13641c536513de8bd85d0ee1ea 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": 1, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "The Glorious Glasgow Haskell Compilation System, version 7.10.2" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":!ghc --version" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 27, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "I have a pen" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":ext OverloadedStrings\n", | |
| "\n", | |
| "import qualified Data.Text as T\n", | |
| "import qualified Data.Text.IO as T\n", | |
| "import Data.Monoid ((<>))\n", | |
| "\n", | |
| "reverseInside' :: T.Text -> T.Text\n", | |
| "reverseInside' word\n", | |
| " | T.length word <= 3 = word\n", | |
| " | otherwise = T.singleton prefix <> T.reverse inside <> T.singleton suffix\n", | |
| " where\n", | |
| " prefix = T.head word\n", | |
| " inside = T.init (T.tail word)\n", | |
| " suffix = T.last word\n", | |
| "\n", | |
| "-- sentence = \"wchih is why Esilgnh is slitl pltcefrey lbilege wehn you wtrie it lkie tihs\"\n", | |
| "sentence = \"I hvae a pen\"\n", | |
| "\n", | |
| "T.putStrLn $ T.unwords $ map reverseInside' (T.words sentence)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 31, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<style>/* Styles used for the Hoogle display in the pager */\n", | |
| ".hoogle-doc {\n", | |
| "display: block;\n", | |
| "padding-bottom: 1.3em;\n", | |
| "padding-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-code {\n", | |
| "display: block;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "}\n", | |
| ".hoogle-text {\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".hoogle-name {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-head {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-sub {\n", | |
| "display: block;\n", | |
| "margin-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-package {\n", | |
| "font-weight: bold;\n", | |
| "font-style: italic;\n", | |
| "}\n", | |
| ".hoogle-module {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-class {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".get-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "white-space: pre-wrap;\n", | |
| "}\n", | |
| ".show-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "margin-left: 1em;\n", | |
| "}\n", | |
| ".mono {\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".err-msg {\n", | |
| "color: red;\n", | |
| "font-style: italic;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "display: block;\n", | |
| "}\n", | |
| "#unshowable {\n", | |
| "color: red;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".err-msg.in.collapse {\n", | |
| "padding-top: 0.7em;\n", | |
| "}\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\n", | |
| ".suggestion-warning { \n", | |
| "font-weight: bold;\n", | |
| "color: rgb(200, 130, 0);\n", | |
| "}\n", | |
| ".suggestion-error { \n", | |
| "font-weight: bold;\n", | |
| "color: red;\n", | |
| "}\n", | |
| ".suggestion-name {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| "</style><span class='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" | |
| }, | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<style>/* Styles used for the Hoogle display in the pager */\n", | |
| ".hoogle-doc {\n", | |
| "display: block;\n", | |
| "padding-bottom: 1.3em;\n", | |
| "padding-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-code {\n", | |
| "display: block;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "}\n", | |
| ".hoogle-text {\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".hoogle-name {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-head {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-sub {\n", | |
| "display: block;\n", | |
| "margin-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-package {\n", | |
| "font-weight: bold;\n", | |
| "font-style: italic;\n", | |
| "}\n", | |
| ".hoogle-module {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-class {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".get-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "white-space: pre-wrap;\n", | |
| "}\n", | |
| ".show-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "margin-left: 1em;\n", | |
| "}\n", | |
| ".mono {\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".err-msg {\n", | |
| "color: red;\n", | |
| "font-style: italic;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "display: block;\n", | |
| "}\n", | |
| "#unshowable {\n", | |
| "color: red;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".err-msg.in.collapse {\n", | |
| "padding-top: 0.7em;\n", | |
| "}\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\n", | |
| ".suggestion-warning { \n", | |
| "font-weight: bold;\n", | |
| "color: rgb(200, 130, 0);\n", | |
| "}\n", | |
| ".suggestion-error { \n", | |
| "font-weight: bold;\n", | |
| "color: red;\n", | |
| "}\n", | |
| ".suggestion-name {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| "</style><span class='get-type'>(<>) :: forall m. Monoid m => m -> m -> m</span>" | |
| ], | |
| "text/plain": [ | |
| "(<>) :: forall m. Monoid m => m -> m -> m" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| }, | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<style>/* Styles used for the Hoogle display in the pager */\n", | |
| ".hoogle-doc {\n", | |
| "display: block;\n", | |
| "padding-bottom: 1.3em;\n", | |
| "padding-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-code {\n", | |
| "display: block;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "}\n", | |
| ".hoogle-text {\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".hoogle-name {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-head {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-sub {\n", | |
| "display: block;\n", | |
| "margin-left: 0.4em;\n", | |
| "}\n", | |
| ".hoogle-package {\n", | |
| "font-weight: bold;\n", | |
| "font-style: italic;\n", | |
| "}\n", | |
| ".hoogle-module {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".hoogle-class {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".get-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "white-space: pre-wrap;\n", | |
| "}\n", | |
| ".show-type {\n", | |
| "color: green;\n", | |
| "font-weight: bold;\n", | |
| "font-family: monospace;\n", | |
| "margin-left: 1em;\n", | |
| "}\n", | |
| ".mono {\n", | |
| "font-family: monospace;\n", | |
| "display: block;\n", | |
| "}\n", | |
| ".err-msg {\n", | |
| "color: red;\n", | |
| "font-style: italic;\n", | |
| "font-family: monospace;\n", | |
| "white-space: pre;\n", | |
| "display: block;\n", | |
| "}\n", | |
| "#unshowable {\n", | |
| "color: red;\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| ".err-msg.in.collapse {\n", | |
| "padding-top: 0.7em;\n", | |
| "}\n", | |
| ".highlight-code {\n", | |
| "white-space: pre;\n", | |
| "font-family: monospace;\n", | |
| "}\n", | |
| ".suggestion-warning { \n", | |
| "font-weight: bold;\n", | |
| "color: rgb(200, 130, 0);\n", | |
| "}\n", | |
| ".suggestion-error { \n", | |
| "font-weight: bold;\n", | |
| "color: red;\n", | |
| "}\n", | |
| ".suggestion-name {\n", | |
| "font-weight: bold;\n", | |
| "}\n", | |
| "</style><span class='get-type'>(++) :: forall a. [a] -> [a] -> [a]</span>" | |
| ], | |
| "text/plain": [ | |
| "(++) :: forall a. [a] -> [a] -> [a]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| }, | |
| { | |
| "data": {}, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| ":t map\n", | |
| ":t (<>)\n", | |
| ":t (++)" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Haskell", | |
| "language": "haskell", | |
| "name": "haskell" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": "ihaskell", | |
| "file_extension": ".hs", | |
| "name": "haskell", | |
| "version": "7.10.2" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment