mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-16 03:16:20 +00:00
167 lines
4.7 KiB
Plaintext
167 lines
4.7 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": [
|
|
"import System.Directory\n",
|
|
"getDirectoryContents \".\""
|
|
],
|
|
"language": "python",
|
|
"metadata": {
|
|
"hidden": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"[\".\",\"..\",\".hdevtools.sock\",\"blog\",\"experiments\",\"hackathon\",\"haskell-course-preludes\",\"haskell-style-guide\",\"ihaskell\",\"ihaskell-app\",\"linal\",\"notes\",\"slinky.nb\",\"tasha\"]"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 9
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":!cd code\n",
|
|
":!pwd\n",
|
|
"setCurrentDirectory \"code\""
|
|
],
|
|
"language": "python",
|
|
"metadata": {
|
|
"hidden": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span class='err-msg'>No such directory: 'code'</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No such directory: 'code'"
|
|
]
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"/Users/silver/code"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"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": {}
|
|
}
|
|
]
|
|
} |