"In order to display a data type, create an instance of `IHaskellDisplay` for your data type \u2013 then, any expression that results in your data type will generate a corresponding display. \n",
"In order to display a data type, create an instance of `IHaskellDisplay` for your data type – then, any expression that results in your data type will generate a corresponding display. \n",
"\n",
"\n",
"Let's go ahead and do this for `CanvasFree a` from the `static-canvas` package."
"Let's go ahead and do this for `CanvasFree a` from the `static-canvas` package."
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false,
"collapsed": false,
"input": [
"hidden": false
},
"outputs": [],
"source": [
"-- Start with necessary imports.\n",
"-- Start with necessary imports.\n",
"import IHaskell.Display -- From the 'ihaskell' package.\n",
"import IHaskell.Display -- From the 'ihaskell' package.\n",
"import IHaskell.IPython.Types(MimeType(..))\n",
"import IHaskell.IPython.Types(MimeType(..))\n",
...
@@ -134,13 +130,7 @@
...
@@ -134,13 +130,7 @@
"-- Text conversion functions.\n",
"-- Text conversion functions.\n",
"import Data.Text.Lazy.Builder(toLazyText)\n",
"import Data.Text.Lazy.Builder(toLazyText)\n",
"import Data.Text.Lazy(toStrict)"
"import Data.Text.Lazy(toStrict)"
],
]
"language": "python",
"metadata": {
"hidden": false
},
"outputs": [],
"prompt_number": 12
},
},
{
{
"cell_type": "markdown",
"cell_type": "markdown",
...
@@ -153,8 +143,13 @@
...
@@ -153,8 +143,13 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false,
"collapsed": false,
"input": [
"hidden": false
},
"outputs": [],
"source": [
"-- Since CanvasFree is a type synonym, we need a language pragma.\n",
"-- Since CanvasFree is a type synonym, we need a language pragma.\n",
"Sadly, it seems that the `static-canvas` library currently only supports having *one* generated canvas on the page \u2013 if you try to add another one, it simply modifies the pre-existing one. This is probably a bug that should be fixed, though!"
"Sadly, it seems that the `static-canvas` library currently only supports having *one* generated canvas on the page – if you try to add another one, it simply modifies the pre-existing one. This is probably a bug that should be fixed, though!"