mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-17 20:06:07 +00:00
734 lines
17 KiB
Plaintext
734 lines
17 KiB
Plaintext
{
|
|
"metadata": {
|
|
"language": "haskell",
|
|
"name": ""
|
|
},
|
|
"nbformat": 3,
|
|
"nbformat_minor": 0,
|
|
"worksheets": [
|
|
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import Diagrams.Prelude\n",
|
|
"import Diagrams.Backend.SVG.CmdLine\n",
|
|
":extension NoMonomorphismRestriction"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"example = circle 1 # fc blue\n",
|
|
" # lw 0.05\n",
|
|
" # lc purple\n",
|
|
" # dashing [0.2,0.05] 0\n",
|
|
"\n",
|
|
"test :: Diagram SVG R2 -> Diagram SVG R2\n",
|
|
"test = id"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 15
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":t example\n",
|
|
":t test example\n",
|
|
":t example :: Diagram B R2"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='font-weight: bold; color: green;'>forall b. (TrailLike b, Transformable b, HasStyle b, V b ~ R2) => b</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"forall b. (TrailLike b, Transformable b, HasStyle b, V b ~ R2) => b"
|
|
]
|
|
},
|
|
{
|
|
"html": [
|
|
"<span style='font-weight: bold; color: green;'>Diagram SVG R2</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Diagram SVG R2"
|
|
]
|
|
},
|
|
{
|
|
"html": [
|
|
"<span style='font-weight: bold; color: green;'>Diagram B R2</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Diagram B R2"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 16
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data M = Z Int deriving Show"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 5
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"print (Z 3)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Z 3"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"ma"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>Not in scope: `ma'<br/>Perhaps you meant one of these:<br/> `map' (imported from Prelude), `max' (imported from Prelude)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Not in scope: `ma'\n",
|
|
"Perhaps you meant one of these:\n",
|
|
" `map' (imported from Prelude), `max' (imported from Prelude)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"f 3 = 2\n",
|
|
"f 2 = 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 7
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"f 2"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"3"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data X = Y Int\n",
|
|
"return (Y 3)\n",
|
|
"Y 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Num String)<br/> arising from the literal `3'<br/>Possible fix:<br/> add an instance declaration for (Num String)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Num.Num GHC.Base.String)\n",
|
|
" arising from the literal `3'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Num.Num GHC.Base.String)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data X = Y Int"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 14
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data X = Y Int deriving Show"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 18
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"Y 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Num String)<br/> arising from the literal `3'<br/>Possible fix:<br/> add an instance declaration for (Num String)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Num.Num GHC.Base.String)\n",
|
|
" arising from the literal `3'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Num.Num GHC.Base.String)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 19
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"test [] = 10"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 20
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"test [3]"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'><interactive>:1:1-12: Non-exhaustive patterns in function test</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"<interactive>:1:1-12: Non-exhaustive patterns in function test"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 21
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":tadaf"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>Parse error (line 1, column 1): Unknown directive: 'tadaf'.</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Parse error (line 1, column 1): Unknown directive: 'tadaf'."
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 22
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"f :: Int -> Int\n",
|
|
"f 10 = 11\n",
|
|
"f 11 = 10\n",
|
|
"f 10"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"11"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 23
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data X = Y Int"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 24
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"let x = 11\n",
|
|
" z = 10 in\n",
|
|
" x+z"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"21"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 25
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":extension OverloadedStrings"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import Prelude hiding (div, id)\n",
|
|
"import Text.Blaze.Html4.Strict hiding (map, style)\n",
|
|
"import Text.Blaze.Html4.Strict.Attributes\n",
|
|
"import Control.Monad\n",
|
|
"div ! style \"color: red\" $ do\n",
|
|
" p \"This is an example of BlazeMarkup syntax.\"\n",
|
|
" p \"Hello\"\n",
|
|
" b \"Hello\"\n",
|
|
" img ! src \"/static/base/images/ipynblogo.png\" ! width \"200\""
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<div style=\"color: red\">\n",
|
|
" <p>\n",
|
|
" This is an example of BlazeMarkup syntax.\n",
|
|
" </p>\n",
|
|
" <p>\n",
|
|
" Hello\n",
|
|
" </p>\n",
|
|
" <b>\n",
|
|
" Hello\n",
|
|
" </b>\n",
|
|
" <img src=\"/static/base/images/ipynblogo.png\" width=\"200\">\n",
|
|
"</div>\n"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"<div style=\"color: red\">\n",
|
|
" <p>\n",
|
|
" This is an example of BlazeMarkup syntax.\n",
|
|
" </p>\n",
|
|
" <p>\n",
|
|
" Hello\n",
|
|
" </p>\n",
|
|
" <b>\n",
|
|
" Hello\n",
|
|
" </b>\n",
|
|
" <img src=\"/static/base/images/ipynblogo.png\" width=\"200\">\n",
|
|
"</div>"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 3
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"forM_ [100, 200, 300, 400, 500, 600, 700, 800] $ \\size -> do\n",
|
|
" let s = show size\n",
|
|
" unsafePerformIO $ do\n",
|
|
" threadDelay 100000\n",
|
|
" putStrLn $ \"Generating size: \" ++ s\n",
|
|
" return $ img ! src \"/static/base/images/ipynblogo.png\" ! width (toValue s)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>Not in scope: `unsafePerformIO'<br/>Not in scope: `threadDelay'</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Not in scope: `unsafePerformIO'\n",
|
|
"Not in scope: `threadDelay'"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import System.IO.Unsafe"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import Prelude hiding (head, id, div)\n",
|
|
"import Text.Blaze.Html4.Strict hiding (map)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 34
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data X = Y Int\n",
|
|
"Y 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Show X)<br/> arising from a use of `print'<br/>Possible fix:<br/> add an instance declaration for (Show X)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Show.Show :Interactive.X)\n",
|
|
" arising from a use of `System.IO.print'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Show.Show :Interactive.X)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"forM [1] $ \\x -> return (Y x)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 59
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":t forM [1] $ \\x -> return (Y x)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='font-weight: bold; color: green;'>forall (m :: * -> *). Monad m => m [X]</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"forall (m :: * -> *). Monad m => m [X]"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 60
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
":t (Y 3)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='font-weight: bold; color: green;'>X</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"X"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 61
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"import Control.Concurrent\n",
|
|
"import Control.Monad\n",
|
|
"\n",
|
|
"forM_ [1..10] $ \\x -> do \n",
|
|
" print x\n",
|
|
" threadDelay 100000"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"1\n",
|
|
"2\n",
|
|
"3\n",
|
|
"4\n",
|
|
"5\n",
|
|
"6\n",
|
|
"7\n",
|
|
"8\n",
|
|
"9\n",
|
|
"10"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 5
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"3"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data Thing = One Int | Two String deriving Show\n",
|
|
"One 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Show Thing)<br/> arising from a use of `print'<br/>Possible fix:<br/> add an instance declaration for (Show Thing)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Show.Show :Interactive.Thing)\n",
|
|
" arising from a use of `System.IO.print'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Show.Show :Interactive.Thing)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"Two \"hello\""
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"Two \"hello\""
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 5
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"One 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Show Thing)<br/> arising from a use of `print'<br/>Possible fix:<br/> add an instance declaration for (Show Thing)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Show.Show :Interactive.Thing)\n",
|
|
" arising from a use of `System.IO.print'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Show.Show :Interactive.Thing)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data Thing = One Int\n",
|
|
"One 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Show Thing)<br/> arising from a use of `print'<br/>Possible fix:<br/> add an instance declaration for (Show Thing)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Show.Show :Interactive.Thing)\n",
|
|
" arising from a use of `System.IO.print'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Show.Show :Interactive.Thing)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"data Thing = One Int deriving Show\n",
|
|
"One 3"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"html": [
|
|
"<span style='color: red; font-style: italic;'>No instance for (Show Thing)<br/> arising from a use of `print'<br/>Possible fix:<br/> add an instance declaration for (Show Thing)</span>"
|
|
],
|
|
"metadata": {},
|
|
"output_type": "display_data",
|
|
"text": [
|
|
"No instance for (GHC.Show.Show :Interactive.Thing)\n",
|
|
" arising from a use of `System.IO.print'\n",
|
|
"Possible fix:\n",
|
|
" add an instance declaration for (GHC.Show.Show :Interactive.Thing)"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": []
|
|
}
|
|
],
|
|
"metadata": {}
|
|
}
|
|
]
|
|
} |