Commit f77a7c3e authored by Sumit Sahrawat's avatar Sumit Sahrawat

Update examples for singleton changes

parent 6622b260
......@@ -70,48 +70,7 @@
"metadata": {
"collapsed": false
},
"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"
}
],
"outputs": [],
"source": [
"-- Display\n",
"chk\n",
......@@ -142,23 +101,23 @@
}
],
"source": [
"setField chk SDescription \"Bool 1: \"\n",
"setField tgb SDescription \"Bool 2\"\n",
"setField chk Description \"Bool 1: \"\n",
"setField tgb Description \"Bool 2\"\n",
"\n",
"-- Helper function\n",
"refresh b =\n",
" let stat = if b then \"green\" else \"red\"\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",
" -- Cosmetic changes\n",
"setField o SDescription \"Bool 1 && Bool 2\"\n",
"setField o SPadding 10\n",
"setField o Description \"Bool 1 && Bool 2\"\n",
"setField o Padding 10\n",
"\n",
" -- And (&&) the two values, and send output to html widget\n",
"setHandler w = setField w SChangeHandler $ do\n",
" b1 <- getField chk SBoolValue\n",
" b2 <- getField tgb SBoolValue\n",
"setHandler w = setField w ChangeHandler $ do\n",
" b1 <- getField chk BoolValue\n",
" b2 <- getField tgb BoolValue\n",
" refresh (b1 && b2)\n",
"\n",
"setHandler chk\n",
......@@ -221,10 +180,10 @@
"sign <- mkCheckBox\n",
"bits <- replicateM 7 mkToggleButton\n",
"\n",
"setField sign SDescription \"Negative\"\n",
"setField sign Description \"Negative\"\n",
"forM_ bits $ \\t -> do\n",
" setField t SButtonStyle PrimaryButton\n",
" setField t SBorderRadius 20"
" setField t ButtonStyle PrimaryButton\n",
" setField t BorderRadius 20"
]
},
{
......@@ -247,116 +206,6 @@
},
"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"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
......@@ -365,26 +214,26 @@
"\n",
"-- Sub-containers\n",
"box1 <- mkFlexBox\n",
"setField box1 SChildren [ChildWidget sign, ChildWidget out]\n",
"setField box1 Children [ChildWidget sign, ChildWidget out]\n",
"box2 <- mkFlexBox\n",
"setField box2 SChildren (map ChildWidget $ reverse bits)\n",
"setField box2 Children (map ChildWidget $ reverse bits)\n",
"\n",
"-- Add widgets to the container\n",
"setField box SChildren (map ChildWidget [box1, box2])\n",
"setField box SOrientation VerticalOrientation\n",
"setField box Children (map ChildWidget [box1, box2])\n",
"setField box Orientation VerticalOrientation\n",
"\n",
"-- Add some UI chrome\n",
"setField box SBoxStyle InfoBox\n",
"setField box SBorderRadius 20\n",
"setField out SBorderStyle GrooveBorder\n",
"setField out SBorderRadius 20\n",
"setField out SBorderWidth 4\n",
"setField out SWidth 100\n",
"setField out SHeight 30\n",
"setField out SMargin 10\n",
"setField sign SPadding 10\n",
"setField box2 SPadding 10\n",
"setField box2 SPack BaselineLocation\n",
"setField box BoxStyle InfoBox\n",
"setField box BorderRadius 20\n",
"setField out BorderStyle GrooveBorder\n",
"setField out BorderRadius 20\n",
"setField out BorderWidth 4\n",
"setField out Width 100\n",
"setField out Height 30\n",
"setField out Margin 10\n",
"setField sign Padding 10\n",
"setField box2 Padding 10\n",
"setField box2 Pack BaselineLocation\n",
"\n",
"-- Display the container\n",
"box"
......@@ -423,19 +272,19 @@
"refresh (x, b) = \n",
" let val = x * if b then (-1) else 1\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",
"setField sign SChangeHandler $ do\n",
"setField sign ChangeHandler $ do\n",
" -- Change sign for value\n",
" modifyIORef val (second not)\n",
" -- Redraw output\n",
" readIORef val >>= refresh\n",
"\n",
"forM_ (zip bits (iterate (*2) 1)) $ \\(t, n) -> do\n",
" setField t SDescription \"0\"\n",
" setField t SChangeHandler $ do\n",
" f <- getField t SBoolValue\n",
" setField t SDescription (if f then \"1\" else \"0\")\n",
" setField t Description \"0\"\n",
" setField t ChangeHandler $ do\n",
" f <- getField t BoolValue\n",
" setField t Description (if f then \"1\" else \"0\")\n",
" modifyIORef val (first $ if f then (+n) else (\\x->x-n))\n",
" readIORef val >>= refresh"
]
......
......@@ -44,225 +44,10 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
"collapsed": false,
"scrolled": true
},
"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": {
"text/html": [
......@@ -373,8 +158,6 @@
}
],
"source": [
":t Children\n",
":t SChildren\n",
":t ChildWidget"
]
},
......@@ -428,8 +211,8 @@
"\n",
"-- Add children widgets to boxes\n",
"let children = map ChildWidget buttons\n",
"setField box SChildren children\n",
"setField flx SChildren children\n",
"setField box Children children\n",
"setField flx Children children\n",
"\n",
"-- Display boxes\n",
"box\n",
......@@ -558,12 +341,14 @@
".suggestion-name {\n",
" font-weight: bold;\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": [
"No instance for (Data.Vinyl.Lens.RElem 'Orientation '[] (Data.Vinyl.TypeLevel.RIndex 'Orientation '[])) arising from a use of ‘setField’\n",
"In the expression: setField box SOrientation VerticalOrientation\n",
"In an equation for ‘it’: it = setField box SOrientation VerticalOrientation"
"No instance for (Data.Vinyl.Lens.RElem\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",
" 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": {},
......@@ -572,14 +357,14 @@
],
"source": [
"-- Trying to set orientation for Boxes\n",
"setField box SOrientation VerticalOrientation"
"setField box Orientation VerticalOrientation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"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 @@
],
"source": [
"-- Trying to set orientation for FlexBox\n",
"setField flx SOrientation VerticalOrientation"
"setField flx Orientation VerticalOrientation"
]
},
{
......@@ -655,8 +440,8 @@
"\n",
"let children = map ChildWidget buttons'\n",
"\n",
"setField acc SChildren children\n",
"setField tab SChildren children\n",
"setField acc Children children\n",
"setField tab Children children\n",
"\n",
"acc\n",
"tab"
......
......@@ -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."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -34,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"collapsed": true
},
......@@ -46,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {
"collapsed": false
},
......@@ -65,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {
"collapsed": false
},
......@@ -79,16 +91,16 @@
}
],
"source": [
"setField bit SMaxInt 20\n",
"setField bit SMinInt 10\n",
"setField bit SChangeHandler (getField bit SIntValue >>= print)"
"setField bit MaxInt 20\n",
"setField bit MinInt 10\n",
"setField bit ChangeHandler (getField bit IntValue >>= print)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"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 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {
"collapsed": true
},
......@@ -119,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {
"collapsed": false
},
......@@ -131,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {
"collapsed": false
},
......@@ -147,7 +159,7 @@
}
],
"source": [
"getField irs SIntPairValue"
"getField irs IntPairValue"
]
},
{
......@@ -166,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {
"collapsed": true
},
......@@ -178,7 +190,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {
"collapsed": false
},
......@@ -192,7 +204,7 @@
}
],
"source": [
"setField inp SIntValue 42"
"setField inp IntValue 42"
]
}
],
......
......@@ -814,7 +814,7 @@
"source": [
"import Text.Printf\n",
"o <- mkOutputWidget -- Make output widget\n",
"setField o SWidth 500\n",
"setField o Width 500\n",
"o -- Display output widget\n",
"\n",
"fmt = \"<font color=\\\"%s\\\"><marquee direction=\\\"%s\\\" style=\\\"background:%s\\\">%s</marquee></font>\"\n",
......
......@@ -63,11 +63,11 @@
}
],
"source": [
"setField msel SDescription \"Functions to show (One or more)\"\n",
"setField msel SOptions (OptionLabels [\"sin\", \"cos\"])\n",
"setField msel Description \"Functions to show (One or more)\"\n",
"setField msel Options (OptionLabels [\"sin\", \"cos\"])\n",
"\n",
"setField tgbs SDescription \"Plot style\"\n",
"setField tgbs SOptions (OptionLabels [\"line\", \"point\"])"
"setField tgbs Description \"Plot style\"\n",
"setField tgbs Options (OptionLabels [\"line\", \"point\"])"
]
},
{
......@@ -110,14 +110,14 @@
" r = [0, 0.1 .. 6.3]\n",
"\n",
"i <- mkImageWidget\n",
"setField i SWidth 500\n",
"setField i SHeight 500\n",
"setField i Width 500\n",
"setField i Height 500\n",
"\n",
"-- Redraw the plot based on values from the widgets\n",
"refresh = do\n",
" -- Read values from the widgets\n",
" funs <- map unpack <$> getField msel SSelectedValues\n",
" sty <- unpack <$> getField tgbs SSelectedValue\n",
" funs <- map unpack <$> getField msel SelectedValues\n",
" sty <- unpack <$> getField tgbs SelectedValue\n",
" \n",
" let pts = zip funs (map (fromJust . flip lookup dset) funs)\n",
" opts = def { _fo_size = (500, 500) }\n",
......@@ -128,14 +128,13 @@
" else mapM_ (\\(s, ps) -> plot (points s ps)) pts\n",
"\n",
" img <- B.readFile \".chart\"\n",
" setField i SB64Value (base64 img)\n",
" setField i B64Value (base64 img)\n",
" \n",
"-- Add event handlers to make widgets work\n",
"setField msel SSelectionHandler refresh\n",
"setField tgbs SSelectionHandler refresh\n",
"setField msel SelectionHandler refresh\n",
"setField tgbs SelectionHandler refresh\n",
"\n",
"-- Set initial value, and trigger event to show initial plot\n",
"setField msel SSelectedLabels [\"sin\"]\n",
"-- Trigger event to show empty grid initially\n",
"triggerSelection msel"
]
},
......@@ -146,6 +145,76 @@
"collapsed": false
},
"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": {},
"metadata": {},
......
......@@ -53,235 +53,6 @@
"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",
"metadata": {},
......@@ -298,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"collapsed": true
},
......@@ -311,37 +82,29 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- Set some html string\n",
"setField html SStringValue \"<b>Bold</b>\""
"setField html StringValue \"<b>Bold</b>\""
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"-- Set some latex string\n",
"setField latex SStringValue \"$x + y$\"\n",
"setField latex StringValue \"$x + y$\"\n",
"\n",
"-- The default width of LatexWidget is somewhat small\n",
"setField latex SWidth 400"
"setField latex Width 400"
]
},
{
......@@ -353,14 +116,14 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"setField html SPadding 10\n",
"setField latex SPadding 10"
"setField html Padding 10\n",
"setField latex Padding 10"
]
},
{
......@@ -379,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {
"collapsed": false
},
......@@ -391,7 +154,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {
"collapsed": false,
"scrolled": true
......@@ -407,7 +170,7 @@
],
"source": [
"-- Some padding\n",
"setField text SPadding 5"
"setField text Padding 5"
]
},
{
......@@ -419,7 +182,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {
"collapsed": false
},
......@@ -433,8 +196,8 @@
}
],
"source": [
"setField text SPlaceholder \"Enter your text here...\"\n",
"setField area SPlaceholder \"Parsed output will appear here...\""
"setField text Placeholder \"Enter your text here...\"\n",
"setField area Placeholder \"Parsed output will appear here...\""
]
},
{
......@@ -453,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {
"collapsed": true
},
......@@ -476,7 +239,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {
"collapsed": true
},
......@@ -537,7 +300,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {
"collapsed": false
},
......@@ -551,12 +314,12 @@
}
],
"source": [
"setField text SChangeHandler $ do\n",
" input <- unpack <$> getField text SStringValue\n",
"setField text ChangeHandler $ do\n",
" input <- unpack <$> getField text StringValue\n",
" str <- case parse phoneNumber \"<text widget>\" input of\n",
" Left error -> return (show error)\n",
" Right x -> return (show x)\n",
" setField area SStringValue (pack str)"
" setField area StringValue (pack str)"
]
},
{
......@@ -575,7 +338,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {
"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