Commit f77a7c3e authored by Sumit Sahrawat's avatar Sumit Sahrawat

Update examples for singleton changes

parent 6622b260
...@@ -70,48 +70,7 @@ ...@@ -70,48 +70,7 @@
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [ "outputs": [],
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
}
],
"source": [ "source": [
"-- Display\n", "-- Display\n",
"chk\n", "chk\n",
...@@ -142,23 +101,23 @@ ...@@ -142,23 +101,23 @@
} }
], ],
"source": [ "source": [
"setField chk SDescription \"Bool 1: \"\n", "setField chk Description \"Bool 1: \"\n",
"setField tgb SDescription \"Bool 2\"\n", "setField tgb Description \"Bool 2\"\n",
"\n", "\n",
"-- Helper function\n", "-- Helper function\n",
"refresh b =\n", "refresh b =\n",
" let stat = if b then \"green\" else \"red\"\n", " let stat = if b then \"green\" else \"red\"\n",
" fmt = \"<div style=\\\"background:%s;color:#ffffff\\\"><b>%s</b></div>\"\n", " fmt = \"<div style=\\\"background:%s;color:#ffffff\\\"><b>%s</b></div>\"\n",
" in setField o SStringValue $ pack $ printf fmt stat (show b)\n", " in setField o StringValue $ pack $ printf fmt stat (show b)\n",
"\n", "\n",
" -- Cosmetic changes\n", " -- Cosmetic changes\n",
"setField o SDescription \"Bool 1 && Bool 2\"\n", "setField o Description \"Bool 1 && Bool 2\"\n",
"setField o SPadding 10\n", "setField o Padding 10\n",
"\n", "\n",
" -- And (&&) the two values, and send output to html widget\n", " -- And (&&) the two values, and send output to html widget\n",
"setHandler w = setField w SChangeHandler $ do\n", "setHandler w = setField w ChangeHandler $ do\n",
" b1 <- getField chk SBoolValue\n", " b1 <- getField chk BoolValue\n",
" b2 <- getField tgb SBoolValue\n", " b2 <- getField tgb BoolValue\n",
" refresh (b1 && b2)\n", " refresh (b1 && b2)\n",
"\n", "\n",
"setHandler chk\n", "setHandler chk\n",
...@@ -221,10 +180,10 @@ ...@@ -221,10 +180,10 @@
"sign <- mkCheckBox\n", "sign <- mkCheckBox\n",
"bits <- replicateM 7 mkToggleButton\n", "bits <- replicateM 7 mkToggleButton\n",
"\n", "\n",
"setField sign SDescription \"Negative\"\n", "setField sign Description \"Negative\"\n",
"forM_ bits $ \\t -> do\n", "forM_ bits $ \\t -> do\n",
" setField t SButtonStyle PrimaryButton\n", " setField t ButtonStyle PrimaryButton\n",
" setField t SBorderRadius 20" " setField t BorderRadius 20"
] ]
}, },
{ {
...@@ -247,116 +206,6 @@ ...@@ -247,116 +206,6 @@
}, },
"metadata": {}, "metadata": {},
"output_type": "display_data" "output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
} }
], ],
"source": [ "source": [
...@@ -365,26 +214,26 @@ ...@@ -365,26 +214,26 @@
"\n", "\n",
"-- Sub-containers\n", "-- Sub-containers\n",
"box1 <- mkFlexBox\n", "box1 <- mkFlexBox\n",
"setField box1 SChildren [ChildWidget sign, ChildWidget out]\n", "setField box1 Children [ChildWidget sign, ChildWidget out]\n",
"box2 <- mkFlexBox\n", "box2 <- mkFlexBox\n",
"setField box2 SChildren (map ChildWidget $ reverse bits)\n", "setField box2 Children (map ChildWidget $ reverse bits)\n",
"\n", "\n",
"-- Add widgets to the container\n", "-- Add widgets to the container\n",
"setField box SChildren (map ChildWidget [box1, box2])\n", "setField box Children (map ChildWidget [box1, box2])\n",
"setField box SOrientation VerticalOrientation\n", "setField box Orientation VerticalOrientation\n",
"\n", "\n",
"-- Add some UI chrome\n", "-- Add some UI chrome\n",
"setField box SBoxStyle InfoBox\n", "setField box BoxStyle InfoBox\n",
"setField box SBorderRadius 20\n", "setField box BorderRadius 20\n",
"setField out SBorderStyle GrooveBorder\n", "setField out BorderStyle GrooveBorder\n",
"setField out SBorderRadius 20\n", "setField out BorderRadius 20\n",
"setField out SBorderWidth 4\n", "setField out BorderWidth 4\n",
"setField out SWidth 100\n", "setField out Width 100\n",
"setField out SHeight 30\n", "setField out Height 30\n",
"setField out SMargin 10\n", "setField out Margin 10\n",
"setField sign SPadding 10\n", "setField sign Padding 10\n",
"setField box2 SPadding 10\n", "setField box2 Padding 10\n",
"setField box2 SPack BaselineLocation\n", "setField box2 Pack BaselineLocation\n",
"\n", "\n",
"-- Display the container\n", "-- Display the container\n",
"box" "box"
...@@ -423,19 +272,19 @@ ...@@ -423,19 +272,19 @@
"refresh (x, b) = \n", "refresh (x, b) = \n",
" let val = x * if b then (-1) else 1\n", " let val = x * if b then (-1) else 1\n",
" fmt = \"<div align=\\\"center\\\"><b>%d</b></div>\"\n", " fmt = \"<div align=\\\"center\\\"><b>%d</b></div>\"\n",
" in setField out SStringValue (pack $ printf fmt val)\n", " in setField out StringValue (pack $ printf fmt val)\n",
"\n", "\n",
"setField sign SChangeHandler $ do\n", "setField sign ChangeHandler $ do\n",
" -- Change sign for value\n", " -- Change sign for value\n",
" modifyIORef val (second not)\n", " modifyIORef val (second not)\n",
" -- Redraw output\n", " -- Redraw output\n",
" readIORef val >>= refresh\n", " readIORef val >>= refresh\n",
"\n", "\n",
"forM_ (zip bits (iterate (*2) 1)) $ \\(t, n) -> do\n", "forM_ (zip bits (iterate (*2) 1)) $ \\(t, n) -> do\n",
" setField t SDescription \"0\"\n", " setField t Description \"0\"\n",
" setField t SChangeHandler $ do\n", " setField t ChangeHandler $ do\n",
" f <- getField t SBoolValue\n", " f <- getField t BoolValue\n",
" setField t SDescription (if f then \"1\" else \"0\")\n", " setField t Description (if f then \"1\" else \"0\")\n",
" modifyIORef val (first $ if f then (+n) else (\\x->x-n))\n", " modifyIORef val (first $ if f then (+n) else (\\x->x-n))\n",
" readIORef val >>= refresh" " readIORef val >>= refresh"
] ]
......
...@@ -44,225 +44,10 @@ ...@@ -44,225 +44,10 @@
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": { "metadata": {
"collapsed": false "collapsed": false,
"scrolled": true
}, },
"outputs": [ "outputs": [
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><span class='get-type'>Children :: Field</span>"
],
"text/plain": [
"Children :: Field"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><span class='get-type'>SChildren :: Sing 'Children</span>"
],
"text/plain": [
"SChildren :: Sing 'Children"
]
},
"metadata": {},
"output_type": "display_data"
},
{ {
"data": { "data": {
"text/html": [ "text/html": [
...@@ -373,8 +158,6 @@ ...@@ -373,8 +158,6 @@
} }
], ],
"source": [ "source": [
":t Children\n",
":t SChildren\n",
":t ChildWidget" ":t ChildWidget"
] ]
}, },
...@@ -428,8 +211,8 @@ ...@@ -428,8 +211,8 @@
"\n", "\n",
"-- Add children widgets to boxes\n", "-- Add children widgets to boxes\n",
"let children = map ChildWidget buttons\n", "let children = map ChildWidget buttons\n",
"setField box SChildren children\n", "setField box Children children\n",
"setField flx SChildren children\n", "setField flx Children children\n",
"\n", "\n",
"-- Display boxes\n", "-- Display boxes\n",
"box\n", "box\n",
...@@ -558,12 +341,14 @@ ...@@ -558,12 +341,14 @@
".suggestion-name {\n", ".suggestion-name {\n",
" font-weight: bold;\n", " font-weight: bold;\n",
"}\n", "}\n",
"</style><span class='err-msg'>No instance for (Data.Vinyl.Lens.RElem 'Orientation '[] (Data.Vinyl.TypeLevel.RIndex 'Orientation '[])) arising from a use of ‘setField’<br/>In the expression: setField box SOrientation VerticalOrientation<br/>In an equation for ‘it’: it = setField box SOrientation VerticalOrientation</span>" "</style><span class='err-msg'>No instance for (Data.Vinyl.Lens.RElem<br/> 'ihaskell-widgets-0.1.0.0:IHaskell.Display.Widgets.Singletons.Orientation '[] (Data.Vinyl.TypeLevel.RIndex 'ihaskell-widgets-0.1.0.0:IHaskell.Display.Widgets.Singletons.Orientation '[]))<br/> arising from a use of ‘setField’<br/>In the expression: setField box Orientation VerticalOrientation<br/>In an equation for ‘it’: it = setField box Orientation VerticalOrientation</span>"
], ],
"text/plain": [ "text/plain": [
"No instance for (Data.Vinyl.Lens.RElem 'Orientation '[] (Data.Vinyl.TypeLevel.RIndex 'Orientation '[])) arising from a use of ‘setField’\n", "No instance for (Data.Vinyl.Lens.RElem\n",
"In the expression: setField box SOrientation VerticalOrientation\n", " 'ihaskell-widgets-0.1.0.0:IHaskell.Display.Widgets.Singletons.Orientation '[] (Data.Vinyl.TypeLevel.RIndex 'ihaskell-widgets-0.1.0.0:IHaskell.Display.Widgets.Singletons.Orientation '[]))\n",
"In an equation for ‘it’: it = setField box SOrientation VerticalOrientation" " arising from a use of ‘setField’\n",
"In the expression: setField box Orientation VerticalOrientation\n",
"In an equation for ‘it’: it = setField box Orientation VerticalOrientation"
] ]
}, },
"metadata": {}, "metadata": {},
...@@ -572,14 +357,14 @@ ...@@ -572,14 +357,14 @@
], ],
"source": [ "source": [
"-- Trying to set orientation for Boxes\n", "-- Trying to set orientation for Boxes\n",
"setField box SOrientation VerticalOrientation" "setField box Orientation VerticalOrientation"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"The errors means that the widget doesn't possess the `Orientation` property." "The error means that the widget doesn't possess the `Orientation` property."
] ]
}, },
{ {
...@@ -599,7 +384,7 @@ ...@@ -599,7 +384,7 @@
], ],
"source": [ "source": [
"-- Trying to set orientation for FlexBox\n", "-- Trying to set orientation for FlexBox\n",
"setField flx SOrientation VerticalOrientation" "setField flx Orientation VerticalOrientation"
] ]
}, },
{ {
...@@ -655,8 +440,8 @@ ...@@ -655,8 +440,8 @@
"\n", "\n",
"let children = map ChildWidget buttons'\n", "let children = map ChildWidget buttons'\n",
"\n", "\n",
"setField acc SChildren children\n", "setField acc Children children\n",
"setField tab SChildren children\n", "setField tab Children children\n",
"\n", "\n",
"acc\n", "acc\n",
"tab" "tab"
......
...@@ -25,6 +25,18 @@ ...@@ -25,6 +25,18 @@
"**NOTE**: Only the `Int` widgets are shown in this notebook. The `Float` widgets are the same as their `Int` counterparts, but hold `Float`s instead of `Int`s." "**NOTE**: Only the `Int` widgets are shown in this notebook. The `Float` widgets are the same as their `Int` counterparts, but hold `Float`s instead of `Int`s."
] ]
}, },
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -34,7 +46,7 @@ ...@@ -34,7 +46,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 2,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -46,7 +58,7 @@ ...@@ -46,7 +58,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -65,7 +77,7 @@ ...@@ -65,7 +77,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 4,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -79,16 +91,16 @@ ...@@ -79,16 +91,16 @@
} }
], ],
"source": [ "source": [
"setField bit SMaxInt 20\n", "setField bit MaxInt 20\n",
"setField bit SMinInt 10\n", "setField bit MinInt 10\n",
"setField bit SChangeHandler (getField bit SIntValue >>= print)" "setField bit ChangeHandler (getField bit IntValue >>= print)"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Now, the first widget will accept arbitrary input whereas the second one wil accept input the the 10-20 range. For example, try entering large values and hitting return/enter in the second widget." "Now, the first widget will accept arbitrary input whereas the second one wil accept input in the the 10-20 range. For example, try entering large values and hitting return/enter in the second widget."
] ]
}, },
{ {
...@@ -107,7 +119,7 @@ ...@@ -107,7 +119,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 5,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -119,7 +131,7 @@ ...@@ -119,7 +131,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 6,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -131,7 +143,7 @@ ...@@ -131,7 +143,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 7,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -147,7 +159,7 @@ ...@@ -147,7 +159,7 @@
} }
], ],
"source": [ "source": [
"getField irs SIntPairValue" "getField irs IntPairValue"
] ]
}, },
{ {
...@@ -166,7 +178,7 @@ ...@@ -166,7 +178,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 8,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -178,7 +190,7 @@ ...@@ -178,7 +190,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 9,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -192,7 +204,7 @@ ...@@ -192,7 +204,7 @@
} }
], ],
"source": [ "source": [
"setField inp SIntValue 42" "setField inp IntValue 42"
] ]
} }
], ],
......
...@@ -814,7 +814,7 @@ ...@@ -814,7 +814,7 @@
"source": [ "source": [
"import Text.Printf\n", "import Text.Printf\n",
"o <- mkOutputWidget -- Make output widget\n", "o <- mkOutputWidget -- Make output widget\n",
"setField o SWidth 500\n", "setField o Width 500\n",
"o -- Display output widget\n", "o -- Display output widget\n",
"\n", "\n",
"fmt = \"<font color=\\\"%s\\\"><marquee direction=\\\"%s\\\" style=\\\"background:%s\\\">%s</marquee></font>\"\n", "fmt = \"<font color=\\\"%s\\\"><marquee direction=\\\"%s\\\" style=\\\"background:%s\\\">%s</marquee></font>\"\n",
......
...@@ -63,11 +63,11 @@ ...@@ -63,11 +63,11 @@
} }
], ],
"source": [ "source": [
"setField msel SDescription \"Functions to show (One or more)\"\n", "setField msel Description \"Functions to show (One or more)\"\n",
"setField msel SOptions (OptionLabels [\"sin\", \"cos\"])\n", "setField msel Options (OptionLabels [\"sin\", \"cos\"])\n",
"\n", "\n",
"setField tgbs SDescription \"Plot style\"\n", "setField tgbs Description \"Plot style\"\n",
"setField tgbs SOptions (OptionLabels [\"line\", \"point\"])" "setField tgbs Options (OptionLabels [\"line\", \"point\"])"
] ]
}, },
{ {
...@@ -110,14 +110,14 @@ ...@@ -110,14 +110,14 @@
" r = [0, 0.1 .. 6.3]\n", " r = [0, 0.1 .. 6.3]\n",
"\n", "\n",
"i <- mkImageWidget\n", "i <- mkImageWidget\n",
"setField i SWidth 500\n", "setField i Width 500\n",
"setField i SHeight 500\n", "setField i Height 500\n",
"\n", "\n",
"-- Redraw the plot based on values from the widgets\n", "-- Redraw the plot based on values from the widgets\n",
"refresh = do\n", "refresh = do\n",
" -- Read values from the widgets\n", " -- Read values from the widgets\n",
" funs <- map unpack <$> getField msel SSelectedValues\n", " funs <- map unpack <$> getField msel SelectedValues\n",
" sty <- unpack <$> getField tgbs SSelectedValue\n", " sty <- unpack <$> getField tgbs SelectedValue\n",
" \n", " \n",
" let pts = zip funs (map (fromJust . flip lookup dset) funs)\n", " let pts = zip funs (map (fromJust . flip lookup dset) funs)\n",
" opts = def { _fo_size = (500, 500) }\n", " opts = def { _fo_size = (500, 500) }\n",
...@@ -128,14 +128,13 @@ ...@@ -128,14 +128,13 @@
" else mapM_ (\\(s, ps) -> plot (points s ps)) pts\n", " else mapM_ (\\(s, ps) -> plot (points s ps)) pts\n",
"\n", "\n",
" img <- B.readFile \".chart\"\n", " img <- B.readFile \".chart\"\n",
" setField i SB64Value (base64 img)\n", " setField i B64Value (base64 img)\n",
" \n", " \n",
"-- Add event handlers to make widgets work\n", "-- Add event handlers to make widgets work\n",
"setField msel SSelectionHandler refresh\n", "setField msel SelectionHandler refresh\n",
"setField tgbs SSelectionHandler refresh\n", "setField tgbs SelectionHandler refresh\n",
"\n", "\n",
"-- Set initial value, and trigger event to show initial plot\n", "-- Trigger event to show empty grid initially\n",
"setField msel SSelectedLabels [\"sin\"]\n",
"triggerSelection msel" "triggerSelection msel"
] ]
}, },
...@@ -146,6 +145,76 @@ ...@@ -146,6 +145,76 @@
"collapsed": false "collapsed": false
}, },
"outputs": [ "outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{ {
"data": {}, "data": {},
"metadata": {}, "metadata": {},
......
...@@ -53,235 +53,6 @@ ...@@ -53,235 +53,6 @@
"These widgets have a `Text` payload, represented by the `StringValue` field." "These widgets have a `Text` payload, represented by the `StringValue` field."
] ]
}, },
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><span class='get-type'>StringValue :: Field</span>"
],
"text/plain": [
"StringValue :: Field"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><span class='get-type'>SStringValue :: Sing 'StringValue</span>"
],
"text/plain": [
"SStringValue :: Sing 'StringValue"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
":t StringValue\n",
":t SStringValue -- singleton"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -298,7 +69,7 @@ ...@@ -298,7 +69,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -311,37 +82,29 @@ ...@@ -311,37 +82,29 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 4,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [ "outputs": [],
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [ "source": [
"-- Set some html string\n", "-- Set some html string\n",
"setField html SStringValue \"<b>Bold</b>\"" "setField html StringValue \"<b>Bold</b>\""
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 5,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"-- Set some latex string\n", "-- Set some latex string\n",
"setField latex SStringValue \"$x + y$\"\n", "setField latex StringValue \"$x + y$\"\n",
"\n", "\n",
"-- The default width of LatexWidget is somewhat small\n", "-- The default width of LatexWidget is somewhat small\n",
"setField latex SWidth 400" "setField latex Width 400"
] ]
}, },
{ {
...@@ -353,14 +116,14 @@ ...@@ -353,14 +116,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 6,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"setField html SPadding 10\n", "setField html Padding 10\n",
"setField latex SPadding 10" "setField latex Padding 10"
] ]
}, },
{ {
...@@ -379,7 +142,7 @@ ...@@ -379,7 +142,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 7,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -391,7 +154,7 @@ ...@@ -391,7 +154,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 8,
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"scrolled": true "scrolled": true
...@@ -407,7 +170,7 @@ ...@@ -407,7 +170,7 @@
], ],
"source": [ "source": [
"-- Some padding\n", "-- Some padding\n",
"setField text SPadding 5" "setField text Padding 5"
] ]
}, },
{ {
...@@ -419,7 +182,7 @@ ...@@ -419,7 +182,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 9,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -433,8 +196,8 @@ ...@@ -433,8 +196,8 @@
} }
], ],
"source": [ "source": [
"setField text SPlaceholder \"Enter your text here...\"\n", "setField text Placeholder \"Enter your text here...\"\n",
"setField area SPlaceholder \"Parsed output will appear here...\"" "setField area Placeholder \"Parsed output will appear here...\""
] ]
}, },
{ {
...@@ -453,7 +216,7 @@ ...@@ -453,7 +216,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 10,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -476,7 +239,7 @@ ...@@ -476,7 +239,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 11,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -537,7 +300,7 @@ ...@@ -537,7 +300,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 12,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -551,12 +314,12 @@ ...@@ -551,12 +314,12 @@
} }
], ],
"source": [ "source": [
"setField text SChangeHandler $ do\n", "setField text ChangeHandler $ do\n",
" input <- unpack <$> getField text SStringValue\n", " input <- unpack <$> getField text StringValue\n",
" str <- case parse phoneNumber \"<text widget>\" input of\n", " str <- case parse phoneNumber \"<text widget>\" input of\n",
" Left error -> return (show error)\n", " Left error -> return (show error)\n",
" Right x -> return (show x)\n", " Right x -> return (show x)\n",
" setField area SStringValue (pack str)" " setField area StringValue (pack str)"
] ]
}, },
{ {
...@@ -575,7 +338,7 @@ ...@@ -575,7 +338,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 13,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment