|
|
|
@ -10,7 +10,9 @@
|
|
|
|
|
"cells": [
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -53,7 +55,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"As you can see, each input cell get an execution number. The first input cell is labeled `In [1]`. Just like in GHCi, the output of the last executed statement or expression is available via the `it` variable - however, in addition, the output of the $n$th cell is available via the `itN` variable. For example, if we wanted to see what the first cell printed, we can go ahead and output that:"
|
|
|
|
|
]
|
|
|
|
@ -79,7 +83,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"In addition to simple code cells such as the ones you see, you can also have other types of cells. All of this inline text, for instance, is written using Markdown cells, which support the majority of Github markdown syntax. This lets you embed images and formatting and arbitrary HTML interspersed with your Haskell code. In addition, you can export these notebooks into HTML or even as presentations using `reveal.js`. \n",
|
|
|
|
|
"\n",
|
|
|
|
@ -112,7 +118,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"In addition to multi-line expressions, IHaskell supports most things that you could put in a standard Haskell file. For example, we can have function bindings without the `let` that GHCi requires. (As long as you group type signatures and their corresponding declarations together, you can use pattern matching and put signatures on your top-level declarations!)"
|
|
|
|
|
]
|
|
|
|
@ -129,7 +137,9 @@
|
|
|
|
|
"thing \"ah\" 10"
|
|
|
|
|
],
|
|
|
|
|
"language": "python",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"metadata": {},
|
|
|
|
@ -150,7 +160,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"So far we've just looked at pure functions, but nothing is stopping us from doing IO."
|
|
|
|
|
]
|
|
|
|
@ -176,7 +188,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"IHaskell supports most GHC extensions via the `:extension` directive (or any shorthand thereof)."
|
|
|
|
|
]
|
|
|
|
@ -194,13 +208,13 @@
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
|
"<span class='err-msg'>`Thing' has no constructors (-XEmptyDataDecls permits this)<br/>In the data declaration for `Thing'</span>"
|
|
|
|
|
"<span class='err-msg'>\u2018interactive:Ghci148.Thing\u2019 has no constructors (EmptyDataDecls permits this)<br/>In the data declaration for \u2018interactive:Ghci148.Thing\u2019</span>"
|
|
|
|
|
],
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "display_data",
|
|
|
|
|
"text": [
|
|
|
|
|
"`Thing' has no constructors (-XEmptyDataDecls permits this)\n",
|
|
|
|
|
"In the data declaration for `Thing'"
|
|
|
|
|
"\u2018interactive:Ghci148.Thing\u2019 has no constructors (EmptyDataDecls permits this)\n",
|
|
|
|
|
"In the data declaration for \u2018interactive:Ghci148.Thing\u2019"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
@ -221,7 +235,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Data declarations do pretty much what you expect, and work fine on multiple lines. If a declaration turns out to be not quite what you wanted, you can just go back, edit it, and re-evaluate the code cell."
|
|
|
|
|
]
|
|
|
|
@ -253,7 +269,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Although this doesn't hold everywhere, we've tried to keep IHaskell relatively similar to GHCi in terms of naming. So, just like in GHCi, you can inspect types with `:type` (or shorthands):"
|
|
|
|
|
]
|
|
|
|
@ -270,12 +288,12 @@
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
|
"<span class='get-type'>forall a. Num a => a</span>"
|
|
|
|
|
"<span class='get-type'>3 + 3 :: forall a. Num a => a</span>"
|
|
|
|
|
],
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "display_data",
|
|
|
|
|
"text": [
|
|
|
|
|
"forall a. Num a => a"
|
|
|
|
|
"3 + 3 :: forall a. Num a => a"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
@ -283,7 +301,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The same goes for the `:info` command. However, unlike GHCi, which simply prints info, the IHaskell notebook brings up a separate pane."
|
|
|
|
|
]
|
|
|
|
@ -307,7 +327,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"If you're looking at this notebook after it's been exported to HTML, you won't be able to see this interactive pane. However, it looks approximately like this:\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -316,7 +338,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"We can now write slightly more complicated scripts."
|
|
|
|
|
]
|
|
|
|
@ -352,7 +376,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"This is where the similarities with GHCi end, and the particularly shiny features of IHaskell begin.\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -372,7 +398,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"If we were playing around with designing GUI applications, for instance, we might want to actually *see* these colors, instead of just seeing the text \"Red\", \"Green\", and \"Blue\" when we are debugging.\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -402,7 +430,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Once we define a custom `display :: a -> IO Display` function, we can simply output a `Color`:"
|
|
|
|
|
]
|
|
|
|
@ -444,7 +474,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The `DisplayData` type has several constructors which let you display your data as plain text, HTML, images (SVG, PNG, JPG), or even as LaTeX code.\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -490,19 +522,12 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
|
"<div class='collapse-group'><span class='btn' href='#' id='unshowable'>Unshowable:<span class='show-type'>NoShow</span></span><span class='err-msg collapse'>No instance for (Show NoShow) arising from a use of `print'<br/>Possible fix: add an instance declaration for (Show NoShow)<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>"
|
|
|
|
|
"<span class='err-msg'>No instance for (Show NoShow) arising from a use of \u2018print\u2019<br/>In a stmt of an interactive GHCi command: print it</span>"
|
|
|
|
|
],
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "display_data",
|
|
|
|
|
"text": [
|
|
|
|
|
"No instance for (Show NoShow) arising from a use of `print'\n",
|
|
|
|
|
"Possible fix: add an instance declaration for (Show NoShow)\n",
|
|
|
|
|
"No instance for (Show NoShow) arising from a use of \u2018print\u2019\n",
|
|
|
|
|
"In a stmt of an interactive GHCi command: print it"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
@ -511,7 +536,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The `ihaskell-aeson` package adds a display for [Aeson](http://hackage.haskell.org/package/aeson) JSON `Value` types. These are automatically syntax highlighted and formatted nicely."
|
|
|
|
|
]
|
|
|
|
@ -534,7 +561,9 @@
|
|
|
|
|
"toJSON (Coord 3 2)"
|
|
|
|
|
],
|
|
|
|
|
"language": "python",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
@ -577,7 +606,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"This syntax highlighting may not show up in the exported HTML, as it is done on the fly with Javascript. The result looks like this in the notebook:\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -586,7 +617,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The `ihaskell-blaze` package lets you play around with HTML straight from within IHaskell using the [Blaze](http://jaspervdj.be/blaze/tutorial.html) library."
|
|
|
|
|
]
|
|
|
|
@ -614,44 +647,15 @@
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
|
"<div style=\"color: red\">\n",
|
|
|
|
|
" <p>\n",
|
|
|
|
|
" This is an example of BlazeMarkup syntax.\n",
|
|
|
|
|
" </p>\n",
|
|
|
|
|
" <b>\n",
|
|
|
|
|
" Hello\n",
|
|
|
|
|
" </b>\n",
|
|
|
|
|
"</div>\n"
|
|
|
|
|
"<span class='err-msg'>Not in scope: \u2018IHaskellPrelude.return\u2019<br/><br/><br/>Not in scope: \u2018IHaskellPrelude.>>\u2019</span>"
|
|
|
|
|
],
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "display_data",
|
|
|
|
|
"text": [
|
|
|
|
|
"<div style=\"color: red\">\n",
|
|
|
|
|
" <p>\n",
|
|
|
|
|
" This is an example of BlazeMarkup syntax.\n",
|
|
|
|
|
" </p>\n",
|
|
|
|
|
" <b>\n",
|
|
|
|
|
" Hello\n",
|
|
|
|
|
" </b>\n",
|
|
|
|
|
"</div>"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"html": [
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"70\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"140\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"210\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"280\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"350\">\n"
|
|
|
|
|
],
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "display_data",
|
|
|
|
|
"text": [
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"70\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"140\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"210\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"280\">\n",
|
|
|
|
|
"<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"350\">"
|
|
|
|
|
"Not in scope: \u2018IHaskellPrelude.return\u2019\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Not in scope: \u2018IHaskellPrelude.>>\u2019"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
@ -659,7 +663,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The `ihaskell-diagrams` package allows you to experiment with the [diagrams](http://projects.haskell.org/diagrams/) package. It requires the Cairo backend."
|
|
|
|
|
]
|
|
|
|
@ -703,7 +709,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Just like with Diagrams, `ihaskell-charts` allows you to use the [Chart](https://github.com/timbod7/haskell-chart/wiki) library for plotting from within IHaskell. (You will need to install `cairo` as well, which may be a bit of a hassle.)"
|
|
|
|
|
]
|
|
|
|
@ -752,7 +760,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"By default, both `ihaskell-diagrams` and `ihaskell-chart` use SVG displays. However, the notebook does not support interactive resizing for SVG image. However, if you use `:set no-svg`, all SVG outputs will instead be shown as PNG images, and they can be resized easily."
|
|
|
|
|
]
|
|
|
|
@ -781,7 +791,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Finally, the `ihaskell-magic` chart uses the [magic](http://hackage.haskell.org/package/magic) library (bindings to `libmagic`) to create a display mechanism for `ByteString`s. If you try to load an image, for instance, you will see that image immediately in the notebook."
|
|
|
|
|
]
|
|
|
|
@ -806,7 +818,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"In addition to displaying outputs in a rich format, IHaskell has a bunch of useful features.\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -892,7 +906,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"If you're an experienced Haskeller, though, and don't want `hlint` telling you what to do, you can easily turn it off:"
|
|
|
|
|
]
|
|
|
|
@ -932,7 +948,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"In addition to `hlint` integration, IHaskell also integrates **Hoogle** for documentation searches. IHaskell provides two directives for searching Hoogle. The first of these, `:document` (or shorthands), looks for exact matches."
|
|
|
|
|
]
|
|
|
|
@ -955,7 +973,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Like with `:info`, the Hoogle directives use the IPython documentation pager to show you their output. You can press Escape to dismiss the pager. If you're reading this in it's HTML form, the output looks like this:\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -964,7 +984,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The other provided command is `:hoogle`. This does a normal Hoogle search, and thus lets you use imperfect matching and searching by type signature."
|
|
|
|
|
]
|
|
|
|
@ -987,7 +1009,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"The pager will show you documentation for things that could have that type signature or a similar one. It automatically formats inline Haskell code and hyperlinks the identifiers to their respective Haddock documentations:\n",
|
|
|
|
|
"\n",
|
|
|
|
@ -996,7 +1020,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"If you need a refresher on all of the options, you can just use `:help`:"
|
|
|
|
|
]
|
|
|
|
@ -1040,7 +1066,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"All of the code you normally put into IHaskell is (like in GHCi) interpreted. However, sometimes you've perfected a function, and now need it to run faster. In that case, you can go ahead and define a module in a single cell. As long as your module has a module header along the lines of `module Name where`, IHaskell will recognize it as a module. It will create the file `A/B.hs`, compile it, and load it. "
|
|
|
|
|
]
|
|
|
|
@ -1063,7 +1091,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Note that the module is by default imported unqualified, as though you had typed `import A.B`."
|
|
|
|
|
]
|
|
|
|
@ -1098,7 +1128,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Note that since a new module is imported, all previous bound identifiers are now unbound. For instance, we no longer have access to the `f` function from before:"
|
|
|
|
|
]
|
|
|
|
@ -1127,7 +1159,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"However, if you re-import this module with another import statement, the original implicit import goes away."
|
|
|
|
|
]
|
|
|
|
@ -1167,7 +1201,9 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"hidden": false
|
|
|
|
|
},
|
|
|
|
|
"source": [
|
|
|
|
|
"Thanks!\n",
|
|
|
|
|
"---\n",
|
|
|
|
|