mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-16 11:26:08 +00:00
179 lines
10 KiB
Plaintext
179 lines
10 KiB
Plaintext
{
|
|
"metadata": {
|
|
"celltoolbar": "Hiding",
|
|
"language": "haskell",
|
|
"name": "",
|
|
"signature": "sha256:7262ddac633b02f026eb4bc29633234f9f8327226256b7f1660e72296f21935b"
|
|
},
|
|
"nbformat": 3,
|
|
"nbformat_minor": 0,
|
|
"worksheets": [
|
|
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import IHaskell.Display\n",
|
|
"\n",
|
|
"-- My widget type\n",
|
|
"data Slider = Slider\n",
|
|
"\n",
|
|
"instance IHaskellDisplay Slider where\n",
|
|
" display Slider = return $ Display []\n",
|
|
" \n",
|
|
"instance IHaskellWidget Slider where\n",
|
|
" targetName _ = \"WidgetModel\"\n",
|
|
" open _ s = s undefined >> error \"what\"\n",
|
|
" "
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":doc map"
|
|
],
|
|
"language": "python",
|
|
"metadata": {
|
|
"hidden": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"html": [
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:map'>map</a> ∷ (a → b) → [a] → [b]</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>base</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Prelude</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>map f xs is the list obtained by applying f to each element of xs, i.e.,\n",
|
|
"</div>\n",
|
|
"<div class='hoogle-text'></div>\n",
|
|
"<div class='hoogle-code'>> map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]\n",
|
|
"> map f [x1, x2, ...] == [f x1, f x2, ...] \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString-Char8.html#v:map'>map</a> ∷ (Char → Char) → ByteString → ByteString</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>bytestring</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.ByteString.Char8</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n) map f xs is the ByteString obtained by applying f to each element of xs \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/text/latest/doc/html/Data-Text.html#v:map'>map</a> ∷ (Char → Char) → Text → Text</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>text</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.Text</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n) map f t is the Text obtained by applying f to each element of t. Subject to fusion. Performs replacement on invalid scalar values. \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-IntSet.html#v:map'>map</a> ∷ (Key → Key) → IntSet → IntSet</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>containers</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.IntSet</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n*min(n,W)). map f s is the set obtained by applying f to each element of s.\n",
|
|
"</div>\n",
|
|
"<div class='hoogle-text'></div>\n",
|
|
"<div class='hoogle-text'>It's worth noting that the size of the result may be smaller if, for some (x,y), x /= y && f x == f y \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString-Lazy.html#v:map'>map</a> ∷ (Word8 → Word8) → ByteString → ByteString</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>bytestring</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.ByteString.Lazy</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n) map f xs is the ByteString obtained by applying f to each element of xs. \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#v:map'>map</a> ∷ (Word8 → Word8) → ByteString → ByteString</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>bytestring</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.ByteString</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n) map f xs is the ByteString obtained by applying f to each element of xs. This function is subject to array fusion. \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-IntMap-Strict.html#v:map'>map</a> ∷ (a → b) → IntMap a → IntMap b</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>containers</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.IntMap.Strict</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n). Map a function over all values in the map.\n",
|
|
"</div>\n",
|
|
"<div class='hoogle-text'></div>\n",
|
|
"<div class='hoogle-code'>> map (++ \"x\") (fromList [(5,\"a\"), (3,\"b\")]) == fromList [(3, \"bx\"), (5, \"ax\")] \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-Map-Lazy.html#v:map'>map</a> ∷ (a → b) → Map k a → Map k b</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>containers</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.Map.Lazy</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n). Map a function over all values in the map.\n",
|
|
"</div>\n",
|
|
"<div class='hoogle-text'></div>\n",
|
|
"<div class='hoogle-code'>> map (++ \"x\") (fromList [(5,\"a\"), (3,\"b\")]) == fromList [(3, \"bx\"), (5, \"ax\")] \n",
|
|
"</div>\n",
|
|
"</div>\n",
|
|
"<span class='hoogle-name'><a target='_blank' href='http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-Set.html#v:map'>map</a> ∷ Ord b ⇒ (a → b) → Set a → Set b</span><span class='hoogle-sub'>(<span class='hoogle-head'>package</span> <span class='hoogle-package'>containers</span>, <span class='hoogle-head'>module</span> <span class='hoogle-module'>Data.Set</span>)</span><div class='hoogle-doc'><div class='hoogle-text'>O(n*log n). map f s is the set obtained by applying f to each element of s.\n",
|
|
"</div>\n",
|
|
"<div class='hoogle-text'></div>\n",
|
|
"<div class='hoogle-text'>It's worth noting that the size of the result may be smaller if, for some (x,y), x /= y && f x == f y \n",
|
|
"</div>\n",
|
|
"</div>\n"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import Text.Parsec\n",
|
|
"import Text.Parsec.String\n",
|
|
"import Text.Parsec.Prim\n",
|
|
"import Text.Parsec.Char\n",
|
|
"\n",
|
|
"data List = List [Float] deriving Show\n",
|
|
"\n",
|
|
"let -- Parse a nonempty int list like [1, 2, 3]\n",
|
|
" parser :: Parser List\n",
|
|
" parser = do\n",
|
|
" char '['\n",
|
|
" values <- option [] $ many1 (try float <|> int)\n",
|
|
" char ']'\n",
|
|
" return $ List values\n",
|
|
" \n",
|
|
" -- Parse an element of an int list, like \"3, \"\n",
|
|
" int :: Parser Float\n",
|
|
" int = do\n",
|
|
" value <- many1 $ oneOf \"0123456789\"\n",
|
|
" optional $ char ','\n",
|
|
" whitespace\n",
|
|
" return (fromIntegral (read value :: Int) :: Float)\n",
|
|
" \n",
|
|
" float :: Parser Float\n",
|
|
" float = do\n",
|
|
" value <- many1 $ oneOf \"0123456789\"\n",
|
|
" char '.'\n",
|
|
" after <- many1 $ oneOf \"0123456789\"\n",
|
|
" optional $ char ','\n",
|
|
" whitespace\n",
|
|
" return (read (value ++ \".\" ++ after) :: Float)\n",
|
|
" \n",
|
|
" -- Parse any whitespace\n",
|
|
" whitespace = many $ oneOf \" \\t\"\n",
|
|
" \n",
|
|
"parser"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<div class='collapse-group'><span class='btn' href='#' id='unshowable'>Unshowable:<span class='show-type'>Parser List</span></span><span class='err-msg collapse'>No instance for (Show (Parser List)) arising from a use of `print'<br/>Possible fix: add an instance declaration for (Show (Parser List))<br/>In a stmt of an interactive GHCi command: print it</span></div><script>$('#unshowable').on('click', function(e) {\n",
|
|
" e.preventDefault();\n",
|
|
" var $this = $(this);\n",
|
|
" var $collapse = $this.closest('.collapse-group').find('.err-msg');\n",
|
|
" $collapse.collapse('toggle');\n",
|
|
"});\n",
|
|
"</script>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (Show (Parser List)) arising from a use of `print'\n",
|
|
"Possible fix: add an instance declaration for (Show (Parser List))\n",
|
|
"In a stmt of an interactive GHCi command: print it"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": []
|
|
}
|
|
],
|
|
"metadata": {}
|
|
}
|
|
]
|
|
} |