diff --git a/ihaskell-display/ihaskell-widgets/Examples/00 Introduction to Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/00 Introduction to Widgets.ipynb
index 4a689f83..7b2c6ae5 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/00 Introduction to Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/00 Introduction to Widgets.ipynb
@@ -103,7 +103,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -137,9 +137,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "setField :: forall f w. (RElemOf f (WidgetFields w), ToKey f, IHaskellWidget (IPythonWidget w), ToPairs (Attr f)) => IPythonWidget w -> FieldType f -> IO ()"
+ ],
+ "text/plain": [
+ "setField :: forall f w. (RElemOf f (WidgetFields w), ToKey f, IHaskellWidget (IPythonWidget w), ToPairs (Attr f)) => IPythonWidget w -> FieldType f -> IO ()"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
":t setField"
]
@@ -148,18 +246,116 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "The `setField` function takes three arguments:\n",
+ "The `setField` function takes three arguments, the first of which is a typelevel argument:\n",
"\n",
- "1. A widget\n",
- "2. A `Field`\n",
+ "1. A type level `Field`\n",
+ "2. A widget\n",
"3. A value for the `Field`"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "getField :: forall f w. RElemOf f (WidgetFields w) => IPythonWidget w -> IO (FieldType f)"
+ ],
+ "text/plain": [
+ "getField :: forall f w. RElemOf f (WidgetFields w) => IPythonWidget w -> IO (FieldType f)"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
":t getField"
]
@@ -168,7 +364,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "The `getField` function takes a `Widget` and a `Field` and returns the value of that `Field` for the `Widget`."
+ "The `getField` function takes a type-level `Field` and a `Widget` value and returns the value of that `Field` for the `Widget`."
]
},
{
@@ -180,9 +376,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "properties :: forall w. IPythonWidget w -> IO ()"
+ ],
+ "text/plain": [
+ "properties :: forall w. IPythonWidget w -> IO ()"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
":t properties"
]
@@ -198,9 +492,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "3"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "\"abc\""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- Showables\n",
"1 + 2\n",
@@ -216,9 +529,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "display :: forall a. IHaskellDisplay a => a -> IO Display"
+ ],
+ "text/plain": [
+ "display :: forall a. IHaskellDisplay a => a -> IO Display"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"import IHaskell.Display\n",
":t display"
@@ -246,9 +657,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "closeWidget :: forall w. IHaskellWidget w => w -> IO ()"
+ ],
+ "text/plain": [
+ "closeWidget :: forall w. IHaskellWidget w => w -> IO ()"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
":t closeWidget"
]
@@ -271,9 +780,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "button :: Button"
+ ],
+ "text/plain": [
+ "button :: Button"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"button <- mkButton -- Construct a Button\n",
":t button"
@@ -288,9 +895,21 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5e8125e2-4d0a-4ce4-902d-aad1922ce61b",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"button -- Display the button"
]
@@ -304,9 +923,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "ViewModule ::: Text\n",
+ "ViewModuleVersion ::: Text\n",
+ "ModelModule ::: Text\n",
+ "ModelModuleVersion ::: Text\n",
+ "ModelName ::: Text\n",
+ "ViewName ::: Text\n",
+ "DOMClasses ::: [Text]\n",
+ "Tabbable ::: Maybe Bool\n",
+ "Tooltip ::: Maybe Text\n",
+ "Layout ::: IPythonWidget LayoutType\n",
+ "DisplayHandler ::: IO ()\n",
+ "Description ::: Text\n",
+ "DescriptionAllowHtml ::: Maybe Bool\n",
+ "Style ::: StyleWidget\n",
+ "Disabled ::: Bool\n",
+ "Icon ::: Text\n",
+ "ButtonStyleField ::: ButtonStyleValue\n",
+ "ClickHandler ::: IO ()"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- The button widget has many properties.\n",
"properties button"
@@ -321,13 +967,13 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import qualified IHaskell.Display.Widgets.Layout as L\n",
- "btnLayout <- getField button Layout\n",
- "setField btnLayout L.Width $ Just \"100%\""
+ "btnLayout <- getField @Layout button\n",
+ "setField @L.Width btnLayout $ Just \"100%\""
]
},
{
@@ -339,15 +985,15 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
- "setField button Description \"Click Me (._.\\\")\"\n",
- "setField button ButtonStyle SuccessButton\n",
- "setField btnLayout L.Border $ Just \"ridge 2px\"\n",
- "setField btnLayout L.Padding $ Just \"10\"\n",
- "setField btnLayout L.Height $ Just \"7em\""
+ "setField @Description button \"Click Me (._.\\\")\"\n",
+ "setField @ButtonStyleField button SuccessButton\n",
+ "setField @L.BorderTop btnLayout $ Just \"ridge 2px\"\n",
+ "setField @L.Padding btnLayout $ Just \"10\"\n",
+ "setField @L.Height btnLayout $ Just \"7em\""
]
},
{
@@ -359,11 +1005,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5e8125e2-4d0a-4ce4-902d-aad1922ce61b",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
- "setField button ClickHandler $ putStrLn \"fO_o\"\n",
+ "setField @ClickHandler button $ putStrLn \"fO_o\"\n",
"button -- Displaying again for convenience"
]
},
@@ -380,11 +1038,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
- "setField button ClickHandler $ getLine >>= putStrLn"
+ "setField @ClickHandler button $ getLine >>= putStrLn"
]
}
],
@@ -400,7 +1058,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb
index 544d1a3b..a22084cc 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb
@@ -26,104 +26,7 @@
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "text/html": [
- "
Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
@@ -146,11 +49,20 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- Check box\n",
"chk <- mkCheckBox\n",
@@ -173,6 +85,7 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -181,7 +94,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f86799d9-7bda-4dcb-885a-d65217634d67",
+ "model_id": "75200e34-c1ee-48d6-98b6-61ff755e96e4",
"version_major": 2,
"version_minor": 0
}
@@ -192,7 +105,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "71753836-ad8a-495f-9257-280feb66fcf5",
+ "model_id": "db9ce2a9-4a3a-4a0f-b50c-380bae1de262",
"version_major": 2,
"version_minor": 0
}
@@ -203,7 +116,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "14bd1aef-8479-43a2-8a10-d6a24561886b",
+ "model_id": "fa3ee396-e46e-4370-a7e0-aa5b521090b7",
"version_major": 2,
"version_minor": 0
}
@@ -214,7 +127,7 @@
],
"source": [
"-- Display the widgets\n",
- "setField tgb Description \"Button\"\n",
+ "setField @Description tgb \"Button\"\n",
"chk\n",
"tgb\n",
"vld"
@@ -233,9 +146,9 @@
"metadata": {},
"outputs": [],
"source": [
- "b1 <- getField chk BoolValue\n",
- "b2 <- getField tgb BoolValue\n",
- "setField vld BoolValue (b1 && b2)"
+ "b1 <- getField @BoolValue chk\n",
+ "b2 <- getField @BoolValue tgb\n",
+ "setField @BoolValue vld (b1 && b2)"
]
},
{
@@ -253,24 +166,25 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
- "setField chk Description \"b1\"\n",
- "setField tgb Description \"b2\"\n",
- "setField vld Description \"b1 && b2:\"\n",
+ "setField @Description chk \"b1\"\n",
+ "setField @Description tgb \"b2\"\n",
+ "setField @Description vld \"b1 && b2:\"\n",
"\n",
"ourBoolHandler :: IO ()\n",
"ourBoolHandler = do\n",
- " b1 <- getField chk BoolValue\n",
- " b2 <- getField tgb BoolValue\n",
- " setField vld BoolValue (b1 && b2)\n",
+ " b1 <- getField @BoolValue chk\n",
+ " b2 <- getField @BoolValue tgb\n",
+ " setField @BoolValue vld (b1 && b2)\n",
"\n",
- "setField chk ChangeHandler ourBoolHandler\n",
- "setField tgb ChangeHandler ourBoolHandler"
+ "setField @ChangeHandler chk ourBoolHandler\n",
+ "setField @ChangeHandler tgb ourBoolHandler"
]
},
{
@@ -293,6 +207,7 @@
"cell_type": "code",
"execution_count": 6,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -315,8 +230,9 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -326,10 +242,10 @@
"sign <- mkCheckBox\n",
"bits <- replicateM 7 mkToggleButton\n",
"\n",
- "setField sign Description \"Negative\"\n",
+ "setField @Description sign \"Negative\"\n",
"forM_ bits $ \\t -> do\n",
- " setField t ButtonStyle PrimaryButton\n",
- " -- setField t BorderRadius 20"
+ " setField @ButtonStyleField t PrimaryButton\n",
+ " -- setField @BorderRadius t 20"
]
},
{
@@ -341,8 +257,9 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 11,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -351,263 +268,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "212247f8-aea0-4eb9-86b9-40b01873e622",
+ "model_id": "cd93f6ed-b871-48cd-b198-d509f1d17cfa",
"version_major": 2,
"version_minor": 0
}
},
"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"
- },
- {
- "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"
- },
- {
- "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": [
@@ -616,20 +283,20 @@
"\n",
"-- Sub-containers\n",
"box1 <- mkBox\n",
- "setField box1 Children [ChildWidget sign, ChildWidget out]\n",
+ "setField @Children box1 [ChildWidget sign, ChildWidget out]\n",
"box2 <- mkBox\n",
- "setField box2 Children (map ChildWidget $ reverse bits)\n",
+ "setField @Children box2 (map ChildWidget $ reverse bits)\n",
"\n",
"-- Add widgets to the container\n",
- "setField box Children (map ChildWidget [box1, box2])\n",
+ "setField @Children box (map ChildWidget [box1, box2])\n",
"\n",
"-- Add some UI chrome\n",
- "setField box BoxStyle InfoBox\n",
- "layout <- getField out Layout\n",
- "setField layout L.Width $ Just \"100px\"\n",
- "setField layout L.Height $ Just \"30px\"\n",
- "setField layout L.Margin $ Just \"10px\"\n",
- "setField layout L.Border $ Just \"4px groove\"\n",
+ "setField @BoxStyle box InfoBox\n",
+ "layout <- getField @Layout out\n",
+ "setField @L.Width layout $ Just \"100px\"\n",
+ "setField @L.Height layout $ Just \"30px\"\n",
+ "setField @L.Margin layout $ Just \"10px\"\n",
+ "setField @L.BorderTop layout $ Just \"4px groove\"\n",
"\n",
"-- Display the container\n",
"box"
@@ -644,21 +311,14 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 12,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"import Control.Arrow (first, second)\n",
"\n",
@@ -670,21 +330,21 @@
"refresh (x, b) = \n",
" let val = x * if b then (-1) else 1\n",
" fmt = \"%d
\"\n",
- " in setField out StringValue (pack $ printf fmt val)\n",
+ " in setField @StringValue out (pack $ printf fmt val)\n",
"\n",
- "setField sign ChangeHandler $ do\n",
+ "setField @ChangeHandler sign $ do\n",
" -- Change sign for value\n",
" modifyIORef val (second not)\n",
" -- Redraw output\n",
" readIORef val >>= refresh\n",
" \n",
- "setField out StringValue \"%d
\"\n",
+ "setField @StringValue out \"%d
\"\n",
"\n",
"forM_ (zip bits (iterate (*2) 1)) $ \\(t, n) -> do\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",
+ " setField @Description t \"0\"\n",
+ " setField @ChangeHandler t $ do\n",
+ " f <- getField @BoolValue t\n",
+ " setField @Description t (if f then \"1\" else \"0\")\n",
" modifyIORef val (first $ if f then (+n) else (\\x->x-n))\n",
" readIORef val >>= refresh"
]
@@ -709,7 +369,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb
index 8b3bcb64..cdfa4e61 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb
@@ -23,104 +23,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets\n",
@@ -177,6 +80,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -208,10 +112,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -223,10 +129,11 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
- "ChildWidget :: forall (w :: WidgetType). RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> ChildWidget"
+ "\n",
+ "ChildWidget :: forall w. RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> ChildWidget"
],
"text/plain": [
- "ChildWidget :: forall (w :: WidgetType). RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> ChildWidget"
+ "ChildWidget :: forall w. RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> ChildWidget"
]
},
"metadata": {},
@@ -248,7 +155,15 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- Create new Boxes and GridBox\n",
"box <- mkBox\n",
@@ -272,7 +187,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "0417bfce-fdb1-4f01-9d03-a470e5aba96e",
+ "model_id": "b283b563-7997-4306-b009-c05ceb7f704e",
"version_major": 2,
"version_minor": 0
}
@@ -283,7 +198,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7477f34f-e4ce-4320-9316-3d542d3a3c08",
+ "model_id": "559f7696-9ac2-4358-94f8-26d22f2814dc",
"version_major": 2,
"version_minor": 0
}
@@ -294,7 +209,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b0876039-5c34-48c7-968f-e8d99811b177",
+ "model_id": "721db87f-08e1-4e1f-8b21-6a6253a9efed",
"version_major": 2,
"version_minor": 0
}
@@ -305,7 +220,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7670dab0-ab1d-4016-a30f-7f0e3a969ebb",
+ "model_id": "9ac8056c-676a-4bee-9ef1-61d012ab7d92",
"version_major": 2,
"version_minor": 0
}
@@ -321,19 +236,19 @@
"buttons <- replicateM 4 mkButton\n",
"\n",
"-- We put its index as description\n",
- "mapM_ (\\(w,i)->setField w Description $ T.pack $ \"Test \" ++ show i) $ zip buttons [1..]\n",
+ "mapM_ (\\(w,i)-> setField @Description w $ T.pack $ \"Test \" ++ show i) $ zip buttons [1..]\n",
"\n",
"-- Add children widgets to boxes\n",
"let children = map ChildWidget buttons\n",
- "setField box Children children\n",
- "setField hbox Children children\n",
- "setField vbox Children children\n",
- "setField gbox Children children\n",
+ "setField @Children box children\n",
+ "setField @Children hbox children\n",
+ "setField @Children vbox children\n",
+ "setField @Children gbox children\n",
"\n",
- "setField box BoxStyle SuccessBox\n",
- "setField vbox BoxStyle InfoBox\n",
- "setField hbox BoxStyle WarningBox\n",
- "setField gbox BoxStyle DangerBox\n",
+ "setField @BoxStyle box SuccessBox\n",
+ "setField @BoxStyle vbox InfoBox\n",
+ "setField @BoxStyle hbox WarningBox\n",
+ "setField @BoxStyle gbox DangerBox\n",
"\n",
"-- Display boxes\n",
"box\n",
@@ -363,8 +278,8 @@
"source": [
"import qualified IHaskell.Display.Widgets.Layout as L\n",
"\n",
- "layout <- getField gbox Layout\n",
- "setField layout L.GridTemplateColumns $ Just \"repeat(2,1fr)\""
+ "layout <- getField @Layout gbox\n",
+ "setField @L.GridTemplateColumns layout $ Just \"repeat(2,1fr)\""
]
},
{
@@ -406,7 +321,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "e9cdff5d-1630-4845-a986-de1ac490e55e",
+ "model_id": "68e855e5-4a69-4a8f-a9d4-b354e9d78ea5",
"version_major": 2,
"version_minor": 0
}
@@ -417,7 +332,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "36172e5a-879c-4584-a74b-17a5c121517a",
+ "model_id": "82cda4f9-ddb0-475e-b645-4bc4ead4c522",
"version_major": 2,
"version_minor": 0
}
@@ -431,10 +346,10 @@
"\n",
"let children = map ChildWidget buttons'\n",
"\n",
- "setField acc Titles $ map (\\x->T.pack $ \"Button \" ++ show x) [1..5]\n",
- "getField acc Titles >>= setField tab Titles\n",
- "setField acc Children children \n",
- "setField tab Children children\n",
+ "setField @Titles acc $ map (\\x->T.pack $ \"Button \" ++ show x) [1..5]\n",
+ "getField @Titles acc >>= setField @Titles tab\n",
+ "setField @Children acc children \n",
+ "setField @Children tab children\n",
"\n",
"acc\n",
"tab"
@@ -449,7 +364,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -472,13 +387,20 @@
}
],
"source": [
- "getField acc SelectedIndex\n",
- "getField tab SelectedIndex\n",
+ "getField @SelectedIndex acc\n",
+ "getField @SelectedIndex tab\n",
"\n",
"-- Let's try closing them\n",
- "setField tab SelectedIndex Nothing\n",
- "setField acc SelectedIndex Nothing"
+ "setField @SelectedIndex tab Nothing\n",
+ "setField @SelectedIndex acc Nothing"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -493,7 +415,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Controller.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Controller.ipynb
index cde047e3..9b0f52c7 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Controller.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Controller.ipynb
@@ -12,14 +12,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"id": "1db1ebee-6896-4a92-9a9c-4d0c0e2fef34",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "a8c7a01e-8962-4053-8726-1053e239a887",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"controller <- mkController\n",
- "setField controller Index 0\n",
+ "setField @Index controller 0\n",
"controller"
]
},
@@ -28,14 +40,55 @@
"execution_count": null,
"id": "463d9488-8941-4e4a-aa47-83ba2f879368",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "False"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "0.0"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
- "getField controller Connected\n",
- "getField controller Name\n",
- "getField controller Timestamp\n",
- "getField controller Mapping\n",
- "getField controller Buttons"
+ "getField @Connected controller\n",
+ "getField @Name controller\n",
+ "getField @Timestamp controller\n",
+ "getField @Mapping controller\n",
+ "getField @Buttons controller"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "732903f0-b50b-4714-b63d-65e54ac2c3c1",
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -50,7 +103,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Layout and Style.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Layout and Style.ipynb
index 0dc63d1b..556c30d1 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Layout and Style.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Layout and Style.ipynb
@@ -16,104 +16,7 @@
"execution_count": 1,
"id": "3643e44d-0220-46be-867e-8e7781fb7bbe",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets\n",
@@ -138,7 +41,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7d321970-3eda-40b4-818f-f468e1942fff",
+ "model_id": "1ede881c-d143-41db-a247-281e2cc0146a",
"version_major": 2,
"version_minor": 0
}
@@ -149,7 +52,7 @@
],
"source": [
"button <- mkButton\n",
- "setField button Description \"Click me!\"\n",
+ "setField @Description button \"Click me!\"\n",
"button"
]
},
@@ -168,7 +71,7 @@
"metadata": {},
"outputs": [],
"source": [
- "layout <- getField button Layout"
+ "layout <- getField @Layout button"
]
},
{
@@ -197,7 +100,10 @@
"LAlignContent ::: Maybe [Char]\n",
"LAlignItems ::: Maybe [Char]\n",
"LAlignSelf ::: Maybe [Char]\n",
- "LBorder ::: Maybe [Char]\n",
+ "LBorderBottom ::: Maybe [Char]\n",
+ "LBorderLeft ::: Maybe [Char]\n",
+ "LBorderRight ::: Maybe [Char]\n",
+ "LBorderTop ::: Maybe [Char]\n",
"LBottom ::: Maybe [Char]\n",
"LDisplay ::: Maybe [Char]\n",
"LFlex ::: Maybe [Char]\n",
@@ -221,10 +127,10 @@
"LMaxWidth ::: Maybe [Char]\n",
"LMinHeight ::: Maybe [Char]\n",
"LMinWidth ::: Maybe [Char]\n",
+ "LObjectFit ::: Maybe [Char]\n",
+ "LObjectPosition ::: Maybe [Char]\n",
"LOrder ::: Maybe [Char]\n",
"LOverflow ::: Maybe [Char]\n",
- "LOverflowX ::: Maybe [Char]\n",
- "LOverflowY ::: Maybe [Char]\n",
"LPadding ::: Maybe [Char]\n",
"LRight ::: Maybe [Char]\n",
"LTop ::: Maybe [Char]\n",
@@ -245,19 +151,11 @@
"execution_count": 5,
"id": "ef00e9aa-3f48-42ff-bb45-9f59b09e78e4",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setField layout L.Height $ Just \"50px\"\n",
- "setField layout L.MinWidth $ Just \"70%\"\n",
- "setField layout L.Padding $ Just \"10px\""
+ "setField @L.Height layout $ Just \"50px\"\n",
+ "setField @L.MinWidth layout $ Just \"70%\"\n",
+ "setField @L.Padding layout $ Just \"10px\""
]
},
{
@@ -289,7 +187,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "bfe255db-9a90-47da-9032-48440e0a0b18",
+ "model_id": "def956c6-a71a-4aa1-b78a-e65b3cb068d8",
"version_major": 2,
"version_minor": 0
}
@@ -361,6 +259,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -392,10 +291,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -407,26 +308,20 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
- "StyleWidget :: forall (w :: WidgetType). RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> StyleWidget"
+ "\n",
+ "StyleWidget :: forall w. RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> StyleWidget"
],
"text/plain": [
- "StyleWidget :: forall (w :: WidgetType). RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> StyleWidget"
+ "StyleWidget :: forall w. RecAll Attr (WidgetFields w) ToPairs => IPythonWidget w -> StyleWidget"
]
},
"metadata": {},
"output_type": "display_data"
- },
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
}
],
"source": [
":t StyleWidget\n",
- "setField slider Style $ StyleWidget style"
+ "setField @Style slider $ StyleWidget style"
]
},
{
@@ -444,7 +339,7 @@
"metadata": {},
"outputs": [],
"source": [
- "setField slider Description \"This is a long description\""
+ "setField @Description slider \"This is a long description\""
]
},
{
@@ -462,7 +357,7 @@
"metadata": {},
"outputs": [],
"source": [
- "setField style DescriptionWidth \"14em\""
+ "setField @DescriptionWidth style \"14em\""
]
},
{
@@ -480,8 +375,8 @@
"metadata": {},
"outputs": [],
"source": [
- "layout <- getField slider Layout\n",
- "setField layout L.Width $ Just \"30em\""
+ "layout <- getField @Layout slider\n",
+ "setField @L.Width layout $ Just \"30em\""
]
},
{
@@ -499,7 +394,7 @@
"metadata": {},
"outputs": [],
"source": [
- "setField style HandleColor $ Just \"pink\""
+ "setField @HandleColor style $ Just \"pink\""
]
}
],
@@ -515,7 +410,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Link Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Link Widgets.ipynb
index fadd6a10..0a63a8b2 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Link Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Link Widgets.ipynb
@@ -2,13 +2,14 @@
"cells": [
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"id": "a0d6ef1e-d8cd-40dc-8928-aa984ea6e788",
"metadata": {},
"outputs": [],
"source": [
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "import IHaskell.Display.Widgets"
+ "{-# LANGUAGE OverloadedStrings, TypeApplications #-}\n",
+ "import IHaskell.Display.Widgets\n",
+ "import Data.Proxy (Proxy(..))"
]
},
{
@@ -29,14 +30,14 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 11,
"id": "107c6fc9-c1fd-433d-8719-fa3daea8bc51",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "bfa03a36-8319-4427-bb4e-79aebec8e97c",
+ "model_id": "a27260ed-9dfe-404a-9bcc-6d3da537794f",
"version_major": 2,
"version_minor": 0
}
@@ -47,43 +48,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "a37ece31-9918-468e-9e8c-c2451f8cdf4a",
+ "model_id": "183bfddc-f461-482e-8640-564bf8c1c3ad",
"version_major": 2,
"version_minor": 0
}
},
"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": [
@@ -93,8 +64,8 @@
"\n",
"-- Creating the link\n",
"link <- mkLink\n",
- "setField link Source (WidgetFieldPair is1 IntValue)\n",
- "setField link Target (WidgetFieldPair is2 IntValue)\n",
+ "setField @Source link (WidgetFieldPair is1 (Proxy @IntValue))\n",
+ "setField @Target link (WidgetFieldPair is2 (Proxy @IntValue))\n",
"\n",
"-- Displaying the widget\n",
"is1\n",
@@ -115,14 +86,14 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 12,
"id": "f71e323b-ac72-42e5-8823-b768d6f9cb58",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "c4a67b75-819a-460f-9de6-7bf39a3000d9",
+ "model_id": "5455e23a-2c44-4481-ac98-041f45f16bb2",
"version_major": 2,
"version_minor": 0
}
@@ -133,283 +104,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9ac97149-889c-43ee-abb5-0cc006956064",
+ "model_id": "9665b5d8-a36b-4216-9d1e-120c3f24e856",
"version_major": 2,
"version_minor": 0
}
},
"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"
- },
- {
- "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"
- },
- {
- "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": [
@@ -419,8 +120,8 @@
"\n",
"-- Making a directional link\n",
"link <- mkDirectionalLink\n",
- "setField link Source (WidgetFieldPair fs1 FloatValue)\n",
- "setField link Target (WidgetFieldPair fi2 IntValue)\n",
+ "setField @Source link (WidgetFieldPair fs1 (Proxy @FloatValue))\n",
+ "setField @Target link (WidgetFieldPair fi2 (Proxy @IntValue))\n",
"\n",
"-- Displaying the sliders\n",
"fs1\n",
@@ -441,7 +142,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 13,
"id": "91ccf115-57b4-4176-b157-0e79c27f4341",
"metadata": {},
"outputs": [
@@ -483,6 +184,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -514,10 +216,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -529,6 +233,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"jsdlink :: WidgetFieldPair -> WidgetFieldPair -> IO DirectionalLink"
],
"text/plain": [
@@ -541,7 +246,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "12cf4ada-4fc9-48c1-981e-ab7121aa9efe",
+ "model_id": "0b0885c4-d023-4bba-a41c-7ca0e53a33e7",
"version_major": 2,
"version_minor": 0
}
@@ -552,7 +257,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "e11c0f79-775d-4597-9990-7496c00334bb",
+ "model_id": "b21ab860-754e-469d-85fb-d6e820466311",
"version_major": 2,
"version_minor": 0
}
@@ -563,48 +268,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "e1690adb-30eb-4cfc-913f-33ad3133aa5b",
+ "model_id": "5d7e4d16-5ba4-4141-9499-72324df2c594",
"version_major": 2,
"version_minor": 0
}
},
"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": [
@@ -614,13 +284,21 @@
"valid <- mkValid\n",
"\n",
"-- The Link widget cannot be displayed, so we ignore the return value\n",
- "_ <- jslink (WidgetFieldPair chk BoolValue) (WidgetFieldPair tgb BoolValue)\n",
- "_ <- jsdlink (WidgetFieldPair chk BoolValue) (WidgetFieldPair valid BoolValue)\n",
+ "_ <- jslink (WidgetFieldPair chk (Proxy @BoolValue)) (WidgetFieldPair tgb (Proxy @BoolValue))\n",
+ "_ <- jsdlink (WidgetFieldPair chk (Proxy @BoolValue)) (WidgetFieldPair valid (Proxy @BoolValue))\n",
"\n",
"chk\n",
"tgb\n",
"valid"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "db91a9da-1075-4264-b633-0ab5a51d22f5",
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -635,7 +313,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Media Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Media Widgets.ipynb
index 06c3a92e..1168bdcd 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Media Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Media Widgets.ipynb
@@ -13,106 +13,9 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 1,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets"
@@ -140,7 +43,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -159,13 +62,13 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "5e350768-e129-4c3b-afff-31543736957d",
+ "model_id": "0658c23f-7cba-4ab9-b6d6-93fad5648695",
"version_major": 2,
"version_minor": 0
}
@@ -177,8 +80,8 @@
"source": [
"png <- get \"https://imgs.xkcd.com/comics/functional.png\"\n",
"img <- mkImage\n",
- "setField img ImageFormat PNG\n",
- "setField img BSValue $ JSONByteString png\n",
+ "setField @ImageFormat img PNG\n",
+ "setField @BSValue img $ JSONByteString png\n",
"img"
]
},
@@ -191,13 +94,13 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7cd95391-858f-43ec-b014-bc1fc6e53241",
+ "model_id": "6397a504-b72e-48b4-8fdc-7acec20c18cc",
"version_major": 2,
"version_minor": 0
}
@@ -208,8 +111,8 @@
],
"source": [
"imgurl <- mkImage\n",
- "setField imgurl ImageFormat IURL\n",
- "setField imgurl BSValue \"https://imgs.xkcd.com/comics/haskell.png\"\n",
+ "setField @ImageFormat imgurl IURL\n",
+ "setField @BSValue imgurl \"https://imgs.xkcd.com/comics/haskell.png\"\n",
"imgurl"
]
},
@@ -224,13 +127,13 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "3be8c81c-a522-4e6a-9529-9fe6f3113b85",
+ "model_id": "bdc1ff8b-8a8d-4050-bd1e-fbcf05a874d0",
"version_major": 2,
"version_minor": 0
}
@@ -241,8 +144,8 @@
],
"source": [
"video <- mkVideo\n",
- "mp4 <- get \"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4\"\n",
- "setField video BSValue $ JSONByteString mp4\n",
+ "mp4 <- get \"https://download.samplelib.com/mp4/sample-5s.mp4\"\n",
+ "setField @BSValue video $ JSONByteString mp4\n",
"video"
]
},
@@ -260,12 +163,12 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
- "setField video Controls False\n",
- "setField video Loop False"
+ "setField @Controls video False\n",
+ "setField @Loop video False"
]
},
{
@@ -278,13 +181,13 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7a887e98-b625-46cd-ad74-1b4b3cfd767a",
+ "model_id": "e5aeffaa-f2d7-4abe-914e-e7f67403b01b",
"version_major": 2,
"version_minor": 0
}
@@ -295,12 +198,19 @@
],
"source": [
"audio <- mkAudio\n",
- "setField audio BSValue \"https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3\"\n",
- "setField audio AudioFormat AURL\n",
- "setField audio Loop False\n",
- "setField audio AutoPlay False\n",
+ "setField @BSValue audio \"https://download.samplelib.com/mp3/sample-12s.mp3\"\n",
+ "setField @AudioFormat audio AURL\n",
+ "setField @Loop audio False\n",
+ "setField @AutoPlay audio False\n",
"audio"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -315,7 +225,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb
index d1d3daff..9bbd3f2b 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb
@@ -32,104 +32,7 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import IHaskell.Display.Widgets"
@@ -151,7 +54,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "0f03d310-6e35-4635-bff5-1b34d78661e4",
+ "model_id": "ef687ad0-ce95-43f7-8e40-45fd169f5d2b",
"version_major": 2,
"version_minor": 0
}
@@ -162,7 +65,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b0535a35-d10c-4887-9559-167cf2e8ab3c",
+ "model_id": "6f226f08-087f-4d38-8bae-ac7740868d57",
"version_major": 2,
"version_minor": 0
}
@@ -210,8 +113,8 @@
}
],
"source": [
- "getField intt IntValue\n",
- "getField floatt FloatValue"
+ "getField @IntValue intt\n",
+ "getField @FloatValue floatt"
]
},
{
@@ -237,8 +140,8 @@
}
],
"source": [
- "x <- getField intt IntValue\n",
- "y <- getField floatt FloatValue\n",
+ "x <- getField @IntValue intt\n",
+ "y <- getField @FloatValue floatt\n",
"\n",
"(fromIntegral x) + y"
]
@@ -256,8 +159,8 @@
"metadata": {},
"outputs": [],
"source": [
- "setField intt StepInt $ Just 5\n",
- "setField floatt StepFloat $ Just 0.5"
+ "setField @StepInt intt $ Just 5\n",
+ "setField @StepFloat floatt $ Just 0.5"
]
},
{
@@ -275,8 +178,8 @@
"metadata": {},
"outputs": [],
"source": [
- "setField intt IntValue 42\n",
- "setField floatt FloatValue 3.14"
+ "setField @IntValue intt 42\n",
+ "setField @FloatValue floatt 3.14"
]
},
{
@@ -294,7 +197,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "0f03d310-6e35-4635-bff5-1b34d78661e4",
+ "model_id": "ef687ad0-ce95-43f7-8e40-45fd169f5d2b",
"version_major": 2,
"version_minor": 0
}
@@ -305,7 +208,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b0535a35-d10c-4887-9559-167cf2e8ab3c",
+ "model_id": "6f226f08-087f-4d38-8bae-ac7740868d57",
"version_major": 2,
"version_minor": 0
}
@@ -315,8 +218,8 @@
}
],
"source": [
- "setField intt ChangeHandler (getField intt IntValue >>= setField floatt FloatValue . (/2) . fromIntegral)\n",
- "setField floatt ChangeHandler (getField floatt FloatValue >>= setField intt IntValue . (*2) . round)\n",
+ "setField @ChangeHandler intt (getField @IntValue intt >>= setField @FloatValue floatt . (/2) . fromIntegral)\n",
+ "setField @ChangeHandler floatt (getField @FloatValue floatt >>= setField @IntValue intt . (*2) . round)\n",
"\n",
"-- Let's display the widgets again so we don't have to scroll up and down\n",
"intt\n",
@@ -340,7 +243,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "653d0c7e-1661-48e2-8844-26aa0bb95bc2",
+ "model_id": "b1af0ae0-8483-418d-9927-d97a520ff23f",
"version_major": 2,
"version_minor": 0
}
@@ -351,7 +254,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "d52da821-8234-40fa-87e4-f20ef6975311",
+ "model_id": "c1a5c813-360c-4e1a-891c-291d900382d0",
"version_major": 2,
"version_minor": 0
}
@@ -365,13 +268,13 @@
"bit <- mkBoundedIntText\n",
"bft <- mkBoundedFloatText\n",
"\n",
- "setField bit MaxInt 5\n",
- "setField bit MinInt (-5)\n",
+ "setField @MaxInt bit 5\n",
+ "setField @MinInt bit (-5)\n",
"\n",
- "setField bft MaxFloat 20\n",
- "setField bft MinFloat 10\n",
- "setField bft StepFloat $ Just 0.5\n",
- "setField bft FloatValue 15\n",
+ "setField @MaxFloat bft 20\n",
+ "setField @MinFloat bft 10\n",
+ "setField @StepFloat bft $ Just 0.5\n",
+ "setField @FloatValue bft 15\n",
"\n",
"bit\n",
"bft"
@@ -409,10 +312,10 @@
"fns <- mkFloatSlider\n",
"fls <- mkFloatLogSlider\n",
"frs <- mkFloatRangeSlider\n",
- "setField fns StepFloat $ Just 0.25\n",
+ "setField @StepFloat fns $ Just 0.25\n",
"-- We can set the base of the logslider\n",
- "setField fls BaseFloat 2\n",
- "setField fls StepFloat $ Just 1"
+ "setField @BaseFloat fls 2\n",
+ "setField @StepFloat fls $ Just 1"
]
},
{
@@ -423,7 +326,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9ef1b79b-2fbf-421b-a340-085f5c406b96",
+ "model_id": "07045bf2-5181-41fc-8fa9-3cdc292107e0",
"version_major": 2,
"version_minor": 0
}
@@ -434,7 +337,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7a4e0717-fd52-45ab-9fd5-6513b1686d3a",
+ "model_id": "de1fd5a4-0ded-42fe-95bc-49458f2a67da",
"version_major": 2,
"version_minor": 0
}
@@ -445,7 +348,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "377be754-1e66-4630-91b6-dbd4878f22df",
+ "model_id": "787ef5b0-bf00-4f1b-8c6d-4efc4a9323b2",
"version_major": 2,
"version_minor": 0
}
@@ -456,7 +359,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "358e4973-0d79-4b1a-ac7a-bddc88e661cf",
+ "model_id": "6832d707-3a51-479e-8860-746803312046",
"version_major": 2,
"version_minor": 0
}
@@ -467,7 +370,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "2ebd3f22-c9c2-4948-a6b8-e301f4f14baa",
+ "model_id": "c1b9da4e-1385-457f-a8e3-bed715536d21",
"version_major": 2,
"version_minor": 0
}
@@ -516,26 +419,18 @@
}
],
"source": [
- "getField irs IntPairValue\n",
- "getField frs FloatPairValue"
+ "getField @IntPairValue irs\n",
+ "getField @FloatPairValue frs"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"-- We can also set the field!\n",
- "setField irs IntPairValue (32,42)"
+ "setField @IntPairValue irs (32,42)"
]
},
{
@@ -553,7 +448,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7a4e0717-fd52-45ab-9fd5-6513b1686d3a",
+ "model_id": "de1fd5a4-0ded-42fe-95bc-49458f2a67da",
"version_major": 2,
"version_minor": 0
}
@@ -564,7 +459,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "0f03d310-6e35-4635-bff5-1b34d78661e4",
+ "model_id": "ef687ad0-ce95-43f7-8e40-45fd169f5d2b",
"version_major": 2,
"version_minor": 0
}
@@ -577,7 +472,7 @@
"gcd a 0 = a\n",
"gcd a b = gcd b $ a `mod` b\n",
"\n",
- "setField irs ChangeHandler (getField irs IntPairValue >>= setField intt IntValue . uncurry gcd)\n",
+ "setField @ChangeHandler irs (getField @IntPairValue irs >>= setField @IntValue intt . uncurry gcd)\n",
"\n",
"irs\n",
"intt"
@@ -596,17 +491,9 @@
"cell_type": "code",
"execution_count": 14,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setField irs ContinuousUpdate False"
+ "setField @ContinuousUpdate irs False"
]
},
{
@@ -622,17 +509,9 @@
"cell_type": "code",
"execution_count": 15,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setField irs Disabled True"
+ "setField @Disabled irs True"
]
},
{
@@ -648,20 +527,12 @@
"cell_type": "code",
"execution_count": 16,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"-- First we're gonna enable the widget again\n",
- "setField irs Disabled False\n",
+ "setField @Disabled irs False\n",
"-- We add 4 trailing zeroes\n",
- "setField irs ReadOutFormat \"04d\"\n",
+ "setField @ReadOutFormat irs \"04d\"\n",
"\n",
"-- We can disable the readout with\n",
"\n",
@@ -690,7 +561,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "fdc5d66a-a7ad-4b84-bd2e-24630eb4adc0",
+ "model_id": "f3523bee-1592-4948-b76d-4c4d5582ce09",
"version_major": 2,
"version_minor": 0
}
@@ -720,8 +591,8 @@
}
],
"source": [
- "setField fnp FloatValue 42.5\n",
- "getField fnp FloatValue"
+ "setField @FloatValue fnp 42.5\n",
+ "getField @FloatValue fnp"
]
},
{
@@ -739,7 +610,7 @@
"metadata": {},
"outputs": [],
"source": [
- "setField fnp Orientation VerticalOrientation"
+ "setField @Orientation fnp VerticalOrientation"
]
},
{
@@ -757,7 +628,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "c615249d-1c83-4e21-8b96-4183cab62964",
+ "model_id": "543962e4-9539-4519-b584-2aafb45cec05",
"version_major": 2,
"version_minor": 0
}
@@ -776,14 +647,14 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"f :: Integer -> IO ()\n",
"f x = do\n",
- " threadDelay (5*10^4)\n",
- " setField inp IntValue x\n",
+ " threadDelay $ 10^5\n",
+ " setField @IntValue inp x\n",
" \n",
"thid <- forkIO $ mapM_ f [0..100]"
]
@@ -799,13 +670,13 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7be98900-12ca-4f6b-8837-0b6679eb933a",
+ "model_id": "ec00ccdc-23d7-44e6-9fc5-a58ed5134b19",
"version_major": 2,
"version_minor": 0
}
@@ -816,7 +687,7 @@
],
"source": [
"play <- mkPlay\n",
- "setField play ChangeHandler (getField play IntValue >>= setField inp IntValue)\n",
+ "setField @ChangeHandler play (getField @IntValue play >>= setField @IntValue inp)\n",
"play"
]
}
@@ -833,7 +704,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Output Widget.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Output Widget.ipynb
index fb9191dd..127f76a2 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Output Widget.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Output Widget.ipynb
@@ -57,6 +57,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -88,10 +89,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -103,6 +106,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"plain :: String -> DisplayData"
],
"text/plain": [
@@ -150,6 +154,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -181,10 +186,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -196,6 +203,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"html :: String -> DisplayData"
],
"text/plain": [
@@ -243,6 +251,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -274,10 +283,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -289,6 +300,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"jpg :: Width -> Height -> Base64 -> DisplayData"
],
"text/plain": [
@@ -336,6 +348,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -367,10 +380,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -382,10 +397,11 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
- "svg :: String -> DisplayData"
+ "\n",
+ "svg :: Text -> DisplayData"
],
"text/plain": [
- "svg :: String -> DisplayData"
+ "svg :: Text -> DisplayData"
]
},
"metadata": {},
@@ -429,6 +445,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -460,10 +477,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -475,6 +494,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"latex :: String -> DisplayData"
],
"text/plain": [
@@ -522,6 +542,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -553,10 +574,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -568,6 +591,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"javascript :: String -> DisplayData"
],
"text/plain": [
@@ -615,6 +639,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -646,10 +671,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -661,6 +688,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"many :: [Display] -> Display"
],
"text/plain": [
@@ -692,7 +720,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "65475610-8b2f-46a6-a3a4-5aa92af8466f",
+ "model_id": "ec372cdf-9e7b-4a64-aa85-19ed9e83fd08",
"version_major": 2,
"version_minor": 0
}
@@ -774,6 +802,7 @@
".hoogle-class {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
".get-type {\n",
"color: green;\n",
"font-weight: bold;\n",
@@ -805,10 +834,12 @@
".err-msg.in.collapse {\n",
"padding-top: 0.7em;\n",
"}\n",
+ "\n",
".highlight-code {\n",
"white-space: pre;\n",
"font-family: monospace;\n",
"}\n",
+ "\n",
".suggestion-warning { \n",
"font-weight: bold;\n",
"color: rgb(200, 130, 0);\n",
@@ -820,6 +851,7 @@
".suggestion-name {\n",
"font-weight: bold;\n",
"}\n",
+ "\n",
"appendDisplay :: forall a. IHaskellDisplay a => OutputWidget -> a -> IO ()"
],
"text/plain": [
@@ -833,8 +865,8 @@
"source": [
":t appendDisplay\n",
"imgurl <- mkImage\n",
- "setField imgurl ImageFormat IURL\n",
- "setField imgurl BSValue \"https://imgs.xkcd.com/comics/functional.png\"\n",
+ "setField @ImageFormat imgurl IURL\n",
+ "setField @BSValue imgurl \"https://imgs.xkcd.com/comics/functional.png\"\n",
"appendDisplay o imgurl"
]
},
@@ -855,7 +887,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "2cc7d38f-dd7f-429d-b14c-eafa2465e4c1",
+ "model_id": "3b7aef3a-e399-4522-bf2b-635ae4df3657",
"version_major": 2,
"version_minor": 0
}
@@ -886,26 +918,19 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "0d5927fc-7a68-4603-beec-0c6376f43707",
+ "model_id": "11540503-fb1a-487d-bf12-21a48445d920",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
- },
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
}
],
"source": [
@@ -915,7 +940,7 @@
"\n",
"-- Making a button\n",
"button <- mkButton\n",
- "setField button Description \"Hi!\"\n",
+ "setField @Description button \"Hi!\"\n",
"\n",
"-- Appending the button to the display\n",
"appendDisplay o button"
@@ -934,7 +959,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Picker Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Picker Widgets.ipynb
index 9281ef9c..d9e063ee 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Picker Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Picker Widgets.ipynb
@@ -2,107 +2,10 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 1,
"id": "c6eaf03d-cf32-448f-949f-1dcafeed8e56",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import Data.Text\n",
@@ -128,14 +31,14 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 2,
"id": "8546ec77-be19-44f3-987e-91eafd890a5a",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "79b44a92-0e84-4efb-9b37-60fb8e7cb579",
+ "model_id": "2287681c-6e9e-4585-97c4-823903305f90",
"version_major": 2,
"version_minor": 0
}
@@ -147,7 +50,7 @@
"source": [
"-- Creating a color widget\n",
"colorPicker <- mkColorPicker\n",
- "setField colorPicker StringValue \"#fabada\"\n",
+ "setField @StringValue colorPicker \"#fabada\"\n",
"colorPicker"
]
},
@@ -161,12 +64,12 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 3,
"id": "phantom-cricket",
"metadata": {},
"outputs": [],
"source": [
- "setField colorPicker Concise True"
+ "setField @Concise colorPicker True"
]
},
{
@@ -179,14 +82,14 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 4,
"id": "continent-given",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "79b44a92-0e84-4efb-9b37-60fb8e7cb579",
+ "model_id": "2287681c-6e9e-4585-97c4-823903305f90",
"version_major": 2,
"version_minor": 0
}
@@ -197,7 +100,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "005e2395-679b-4311-90bb-f793e92b2769",
+ "model_id": "a2fc28ac-9bab-4fcd-9c1d-28324848ee24",
"version_major": 2,
"version_minor": 0
}
@@ -210,17 +113,17 @@
"-- Creating the button and style\n",
"b <- mkButton\n",
"stl <- mkButtonStyle\n",
- "setField b Style $ StyleWidget stl\n",
+ "setField @Style b $ StyleWidget stl\n",
"\n",
"-- Creating the handler\n",
"colorHandler :: IO ()\n",
- "colorHandler = getField colorPicker StringValue >>= setField stl ButtonColor . Just . unpack\n",
+ "colorHandler = getField @StringValue colorPicker >>= setField @ButtonColor stl . Just . unpack\n",
"-- calling the handler to initialize the button\n",
"colorHandler\n",
"\n",
"-- Setting color picker attributes\n",
- "setField colorPicker Concise False\n",
- "setField colorPicker ChangeHandler colorHandler\n",
+ "setField @Concise colorPicker False\n",
+ "setField @ChangeHandler colorPicker colorHandler\n",
"\n",
"-- Displaying the widgets\n",
"colorPicker\n",
@@ -239,30 +142,20 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 5,
"id": "fe024e0b-7b08-4fc9-ba22-1e706d31b4b8",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "29a2ae24-caf1-44a0-8275-b60fb4607134",
+ "model_id": "cf98b4a3-8547-4006-b224-fe6df0f079b7",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
- },
- {
- "data": {},
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {},
- "metadata": {},
- "output_type": "display_data"
}
],
"source": [
@@ -280,14 +173,14 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 8,
"id": "purple-specification",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "Today's date is 19/8/2021"
+ "Today's date is 16/10/2024"
]
},
"metadata": {},
@@ -295,7 +188,7 @@
}
],
"source": [
- "(Date y m d) <- getField datePicker DateValue\n",
+ "(Date y m d) <- getField @DateValue datePicker\n",
"printf \"Today's date is %d/%d/%d\" d m y"
]
},
@@ -309,12 +202,12 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": null,
"id": "5789b89d-f0d9-47b8-888f-54d30f4b2a27",
"metadata": {},
"outputs": [],
"source": [
- "setField datePicker DateValue NullDate"
+ "setField @DateValue datePicker NullDate"
]
}
],
@@ -330,7 +223,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb
index 9ddd1587..3719d3aa 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb
@@ -11,106 +11,9 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
@@ -126,7 +29,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -134,6 +37,7 @@
"import Data.Monoid (mempty)\n",
"import Data.Text (Text)\n",
"import qualified Data.Map as M\n",
+ "import Data.Proxy\n",
"\n",
"data PlotInfo = PlotInfo {\n",
" plotTitle :: String,\n",
@@ -175,7 +79,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -188,8 +92,8 @@
"\n",
"tempImgWidget <- mkImage\n",
"\n",
- "setField tempImgWidget Width 400\n",
- "setField tempImgWidget Height 400\n",
+ "setField @Width tempImgWidget 400\n",
+ "setField @Height tempImgWidget 400\n",
"\n",
"plotState <- newIORef defaultPlotInfo\n",
"\n",
@@ -198,7 +102,7 @@
"update modifier = readIORef plotState >>= modifier >>= writeIORef plotState >> redraw\n",
"\n",
"redraw :: IO ()\n",
- "redraw = readIORef plotState >>= mkPlot >>= setField tempImgWidget BSValue . JSONByteString\n",
+ "redraw = readIORef plotState >>= mkPlot >>= setField @BSValue tempImgWidget . JSONByteString\n",
"\n",
"mkDset :: PlotInfo -> [(String, [(Double, Double)])]\n",
"mkDset info = let funcs = M.toList $ functions info\n",
@@ -246,17 +150,9 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"divBox <- mkHBox\n",
"\n",
@@ -265,7 +161,7 @@
"tlBox <- mkAccordion\n",
"\n",
"-- Add the widgets to the main dividing box.\n",
- "setField divBox Children [ChildWidget plBox, ChildWidget tlBox]"
+ "setField @Children divBox [ChildWidget plBox, ChildWidget tlBox]"
]
},
{
@@ -280,17 +176,9 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"slBox <- mkVBox\n",
"\n",
@@ -298,7 +186,7 @@
"let plImg = tempImgWidget\n",
"\n",
"-- Add widgets to the plotting region.\n",
- "setField plBox Children [ChildWidget slBox, ChildWidget plImg]"
+ "setField @Children plBox [ChildWidget slBox, ChildWidget plImg]"
]
},
{
@@ -314,17 +202,9 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"-- The four FlexBox widgets.\n",
"import Control.Monad (replicateM, forM_)\n",
@@ -340,8 +220,8 @@
"inpts@[plInp,xInp,yInp] <- replicateM 3 mkBoundedFloatText\n",
"\n",
"-- Adding event handlers for text widgets. This is a clumsy way to emulate first-class record fields.\n",
- "let setHandler widget field = setField widget ChangeHandler $ update $ \\info -> do\n",
- " newStr <- getField widget StringValue\n",
+ "let setHandler widget field = setField @ChangeHandler widget $ update $ \\info -> do\n",
+ " newStr <- getField @StringValue widget\n",
" return $ field info newStr\n",
" in do\n",
" setHandler plTxt $ \\struct val -> struct { plotTitle = unpack val }\n",
@@ -349,8 +229,8 @@
" setHandler yTxt $ \\struct val -> struct { yLabel = unpack val }\n",
"\n",
"-- Adding events for the numeric input widgets.\n",
- "let setHandler widget field = setField widget ChangeHandler $ update $ \\info -> do\n",
- " newNum <- getField widget FloatValue\n",
+ "let setHandler widget field = setField @ChangeHandler widget $ update $ \\info -> do\n",
+ " newNum <- getField @FloatValue widget\n",
" return $ field info newNum\n",
" in do\n",
" setHandler plInp $ \\struct val -> struct { plotTitleSize = val }\n",
@@ -360,26 +240,18 @@
"let boxInfo = zip4 boxes texts inpts [\"plot title\", \"X-Label\", \"Y-Label\"]\n",
"\n",
"forM_ boxInfo $ \\(box,text,input,placeholder) -> do\n",
- " setField box Children [ChildWidget text, ChildWidget input]\n",
- " setField text Placeholder $ pack $ printf \"Enter %s here ...\" placeholder\n",
- " setField input MinFloat 1\n",
- " setField input MaxFloat 72\n",
- " setField input FloatValue 10"
+ " setField @Children box [ChildWidget text, ChildWidget input]\n",
+ " setField @Placeholder text $ pack $ printf \"Enter %s here ...\" placeholder\n",
+ " setField @MinFloat input 1\n",
+ " setField @MaxFloat input 72\n",
+ " setField @FloatValue input 10"
]
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"-- A FlexBox with ToggleButtons\n",
"buttonBox <- mkHBox\n",
@@ -387,33 +259,25 @@
"\n",
"let tgButtonInfo = zip tButtons [\"X-Grid\", \"Y-Grid\"]\n",
"\n",
- "let setHandler widget fieldSetter = setField widget ChangeHandler $ update $ \\info -> do\n",
- " newStr <- getField widget BoolValue\n",
+ "let setHandler widget fieldSetter = setField @ChangeHandler widget $ update $ \\info -> do\n",
+ " newStr <- getField @BoolValue widget\n",
" return $ fieldSetter info newStr\n",
" in do\n",
" setHandler xGrid $ \\struct val -> struct { showXGrid = val }\n",
" setHandler yGrid $ \\struct val -> struct { showYGrid = val }\n",
"\n",
"forM_ tgButtonInfo $ \\(widget, description) -> do\n",
- " setField widget Description description\n",
- " setField widget BoolValue True\n",
+ " setField @Description widget description\n",
+ " setField @BoolValue widget True\n",
"\n",
- "setField buttonBox Children (map ChildWidget tButtons)"
+ "setField @Children buttonBox (map ChildWidget tButtons)"
]
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"import Control.Arrow (first, second)\n",
"\n",
@@ -424,10 +288,10 @@
"let rangeInfo = zip rangeBoxes [(xLow,xHigh), (yLow, yHigh)]\n",
"\n",
"forM_ rangeInfo $ \\(box, (lowTxt, highTxt)) -> do\n",
- " setField box Children (map ChildWidget [lowTxt, highTxt])\n",
+ " setField @Children box (map ChildWidget [lowTxt, highTxt])\n",
"\n",
- "let setHandler widget modifier = setField widget ChangeHandler $ update $ \\info -> do\n",
- " val <- getField widget FloatValue\n",
+ "let setHandler widget modifier = setField @ChangeHandler widget $ update $ \\info -> do\n",
+ " val <- getField @FloatValue widget\n",
" return $ modifier val info\n",
" in do\n",
" setHandler xLow $ \\v p -> p { xRange = first (const v) (xRange p) }\n",
@@ -445,19 +309,11 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setField tlBox Children $ map ChildWidget $ boxes ++ [buttonBox] ++ rangeBoxes"
+ "setField @Children tlBox $ map ChildWidget $ boxes ++ [buttonBox] ++ rangeBoxes"
]
},
{
@@ -469,11 +325,11 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "setField tlBox Titles [\"Plot title\", \"X-Label\", \"Y-Label\", \"Grid\", \"X-range\", \"Y-range\"]"
+ "setField @Titles tlBox [\"Plot title\", \"X-Label\", \"Y-Label\", \"Grid\", \"X-range\", \"Y-range\"]"
]
},
{
@@ -485,35 +341,27 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "let syncVal widget value fieldGetter = readIORef plotState >>= setField widget value . fieldGetter\n",
- " in do\n",
- " syncVal plTxt StringValue (pack . plotTitle)\n",
- " syncVal plInp FloatValue plotTitleSize\n",
+ "syncVal (Proxy :: Proxy v) widget fieldGetter = readIORef plotState >>= setField @v widget . fieldGetter\n",
"\n",
- " syncVal xTxt StringValue (pack . xLabel)\n",
- " syncVal xInp FloatValue xLabelSize\n",
- " syncVal yTxt StringValue (pack . yLabel)\n",
- " syncVal yInp FloatValue yLabelSize\n",
+ "syncVal (Proxy @StringValue) plTxt (pack . plotTitle)\n",
+ "syncVal (Proxy @FloatValue) plInp plotTitleSize\n",
"\n",
- " syncVal xGrid BoolValue showXGrid\n",
- " syncVal yGrid BoolValue showYGrid\n",
+ "syncVal (Proxy @StringValue) xTxt (pack . xLabel)\n",
+ "syncVal (Proxy @FloatValue) xInp xLabelSize\n",
+ "syncVal (Proxy @StringValue) yTxt (pack . yLabel)\n",
+ "syncVal (Proxy @FloatValue) yInp yLabelSize\n",
"\n",
- " syncVal xLow FloatValue (fst . xRange)\n",
- " syncVal xHigh FloatValue (snd . xRange)\n",
- " syncVal yLow FloatValue (fst . yRange)\n",
- " syncVal yHigh FloatValue (snd . yRange)"
+ "syncVal (Proxy @BoolValue) xGrid showXGrid\n",
+ "syncVal (Proxy @BoolValue) yGrid showYGrid\n",
+ "\n",
+ "syncVal (Proxy @FloatValue) xLow (fst . xRange)\n",
+ "syncVal (Proxy @FloatValue) xHigh (snd . xRange)\n",
+ "syncVal (Proxy @FloatValue) yLow (fst . yRange)\n",
+ "syncVal (Proxy @FloatValue) yHigh (snd . yRange)"
]
},
{
@@ -525,7 +373,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -545,226 +393,9 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "e094c747-9265-41f1-8c61-4f06b6316d0f",
- "version_major": 2,
- "version_minor": 0
- }
- },
- "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"
- },
- {
- "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"
- }
- ],
+ "outputs": [],
"source": [
"-- Spurious update to display empty plot instead of empty image initially\n",
"update return\n",
@@ -781,7 +412,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -790,7 +421,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -799,7 +430,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -826,7 +457,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Selection Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Selection Widgets.ipynb
index 7ddc3b3d..f2a9553d 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Selection Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Selection Widgets.ipynb
@@ -30,104 +30,7 @@
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
@@ -138,11 +41,20 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- Allows single selection\n",
"tgbs <- mkToggleButtons\n",
@@ -167,13 +79,13 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "cc3cb3ef-76c6-45d4-8d94-c9f904128b63",
+ "model_id": "3abd4c34-c04f-4f59-b20c-a25206aa6a93",
"version_major": 2,
"version_minor": 0
}
@@ -184,7 +96,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "a217e3a5-6b3a-4195-93f3-3e47a59e7780",
+ "model_id": "c436f5dc-68b8-4265-b7fe-3cde44221ab5",
"version_major": 2,
"version_minor": 0
}
@@ -195,7 +107,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b7e86ecf-da03-4550-9ea9-98649e31b3d3",
+ "model_id": "c9292a02-4ba3-435c-8202-92581524ba8d",
"version_major": 2,
"version_minor": 0
}
@@ -206,7 +118,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9b3a0173-3f8f-4023-97f4-347dd6665f3a",
+ "model_id": "579036b8-e825-4cfb-9c81-da728601c099",
"version_major": 2,
"version_minor": 0
}
@@ -217,29 +129,19 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f4e42990-e405-47c1-97f0-0f8de2eb8cd9",
+ "model_id": "4a4f263e-f56a-4af1-88db-b97510e941b2",
"version_major": 2,
"version_minor": 0
}
},
"metadata": {},
"output_type": "display_data"
- },
- {
- "data": {},
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {},
- "metadata": {},
- "output_type": "display_data"
}
],
"source": [
"init w = do\n",
- " setField w Description \"Function:\"\n",
- " setField w OptionsLabels [\"sin\", \"cos\"]\n",
+ " setField @Description w \"Function:\"\n",
+ " setField @OptionsLabels w [\"sin\", \"cos\"]\n",
" return w\n",
" \n",
"init tgbs\n",
@@ -258,36 +160,28 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 4,
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setHandlerOpt w = setField w SelectionHandler $ do\n",
- " y <- getField w OptionalIndex\n",
+ "setHandlerOpt w = setField @SelectionHandler w $ do\n",
+ " y <- getField @OptionalIndex w\n",
" case y of\n",
" Just x -> do\n",
- " setField dropdown OptionalIndex $ Just x\n",
- " setField tgbs OptionalIndex $ Just x\n",
- " setField radio OptionalIndex $ Just x\n",
- " setField select OptionalIndex $ Just x\n",
- " setField slider Index x\n",
+ " setField @OptionalIndex dropdown $ Just x\n",
+ " setField @OptionalIndex tgbs $ Just x\n",
+ " setField @OptionalIndex radio $ Just x\n",
+ " setField @OptionalIndex select $ Just x\n",
+ " setField @Index slider x\n",
" _ -> return ()\n",
" \n",
- "setHandler w = setField w SelectionHandler $ do\n",
- " x <- getField w Index\n",
- " setField dropdown OptionalIndex $ Just x\n",
- " setField tgbs OptionalIndex $ Just x\n",
- " setField radio OptionalIndex $ Just x\n",
- " setField select OptionalIndex $ Just x\n",
- " setField slider Index x\n",
+ "setHandler w = setField @SelectionHandler w $ do\n",
+ " x <- getField @Index w\n",
+ " setField @OptionalIndex dropdown $ Just x\n",
+ " setField @OptionalIndex tgbs $ Just x\n",
+ " setField @OptionalIndex radio $ Just x\n",
+ " setField @OptionalIndex select $ Just x\n",
+ " setField @Index slider x\n",
" \n",
"\n",
"setHandlerOpt tgbs\n",
@@ -310,13 +204,13 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f687e5f8-3df0-4e27-aad2-42e439a32491",
+ "model_id": "ebad2164-fc83-4aad-813d-ea44eae2338d",
"version_major": 2,
"version_minor": 0
}
@@ -333,7 +227,7 @@
" , \"Madrid\", \"Extremadura\", \"Galicia\", \"La Rioja\", \"Navarre\", \"Murcia\", \"Valencia\"\n",
" ]\n",
" \n",
- "setField msel OptionsLabels ccaa\n",
+ "setField @OptionsLabels msel ccaa\n",
"msel"
]
},
@@ -346,11 +240,11 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
- "setField msel Indices [0,2]"
+ "setField @Indices msel [0,2]"
]
},
{
@@ -362,11 +256,11 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
- "setField msel Rows $ Just 10"
+ "setField @Rows msel $ Just 10"
]
},
{
@@ -378,43 +272,23 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "ef3f3191-b86b-4ad8-be4f-b824b9e15786",
+ "model_id": "2fe820d9-9fb7-492a-b126-410c8533098b",
"version_major": 2,
"version_minor": 0
}
},
"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": [
- "setField rslider OptionsLabels [\"Very bad\", \"Bad\", \"Regular\", \"Good\", \"Very good\"]\n",
+ "setField @OptionsLabels rslider [\"Very bad\", \"Bad\", \"Regular\", \"Good\", \"Very good\"]\n",
"rslider"
]
},
@@ -427,13 +301,13 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[1,3]"
+ "[0,0]"
]
},
"metadata": {},
@@ -441,9 +315,16 @@
}
],
"source": [
- "getField rslider Indices\n",
- "setField rslider Indices [1,3]"
+ "getField @Indices rslider\n",
+ "setField @Indices rslider [1,3]"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -458,7 +339,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/String Widgets.ipynb b/ihaskell-display/ihaskell-widgets/Examples/String Widgets.ipynb
index 3f22370d..61c22b22 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/String Widgets.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/String Widgets.ipynb
@@ -27,104 +27,7 @@
"metadata": {
"tags": []
},
- "outputs": [
- {
- "data": {
- "text/html": [
- "Unused LANGUAGE pragma
Found:
{-# LANGUAGE OverloadedStrings #-}
"
- ],
- "text/plain": [
- "Line 1: Unused LANGUAGE pragma\n",
- "Found:\n",
- "{-# LANGUAGE OverloadedStrings #-}\n",
- "Why not:"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
@@ -133,13 +36,22 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 2,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"-- Constructors\n",
"html <- mkHTML\n",
@@ -172,7 +84,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 3,
"metadata": {
"tags": []
},
@@ -180,7 +92,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7d9bbee6-5fc5-4790-b5ae-500d1966750f",
+ "model_id": "4077fda1-f1cf-4ebf-b560-24d3e031b89e",
"version_major": 2,
"version_minor": 0
}
@@ -196,8 +108,9 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 4,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -205,13 +118,14 @@
"outputs": [],
"source": [
"-- Set some html string\n",
- "setField html StringValue \"Hello World!\""
+ "setField @StringValue html \"Hello World!\""
]
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 5,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -220,7 +134,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7503927b-868d-42d3-b523-80b1beb891cd",
+ "model_id": "2088fa59-fae3-4756-a7c2-d1ff2adfc298",
"version_major": 2,
"version_minor": 0
}
@@ -231,7 +145,7 @@
],
"source": [
"-- Set some latex string\n",
- "setField htmlMath StringValue \"$$\\\\sum_{i=0}^{i < n} i =\\\\frac{n\\\\cdot(n+1)}{2}$$\"\n",
+ "setField @StringValue htmlMath \"$$\\\\sum_{i=0}^{i < n} i =\\\\frac{n\\\\cdot(n+1)}{2}$$\"\n",
"htmlMath"
]
},
@@ -251,8 +165,9 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 6,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
@@ -261,7 +176,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "93ea02c6-5afc-4e10-813e-3a7d019e4688",
+ "model_id": "1574dfdc-b482-4da1-8d54-4090a0c29632",
"version_major": 2,
"version_minor": 0
}
@@ -272,7 +187,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "f06f4e78-7ad0-4309-b094-7f797278ed1e",
+ "model_id": "97e3569f-0081-444c-86b6-9e65ab499163",
"version_major": 2,
"version_minor": 0
}
@@ -283,43 +198,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "a5a7eea1-3090-4351-a021-65618ddaa5a5",
+ "model_id": "498d1b85-fca3-48a3-84aa-17822e960bf6",
"version_major": 2,
"version_minor": 0
}
},
"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": [
@@ -341,56 +226,51 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 7,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
- "setField text Placeholder \"Enter your text here...\"\n",
- "setField pass Placeholder \"Password\"\n",
- "setField area Placeholder \"Parsed output will appear here...\""
+ "setField @Placeholder text \"Enter your text here...\"\n",
+ "setField @Placeholder pass \"Password\"\n",
+ "setField @Placeholder area \"Parsed output will appear here...\""
]
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
- "text/plain": [
- "\"\""
- ]
+ "text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "text/plain": [
- "\"agsagsa\""
- ]
+ "text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
- "text/plain": [
- "\"\""
- ]
+ "text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
- "getField text StringValue\n",
- "getField pass StringValue\n",
- "getField area StringValue"
+ "getField @StringValue text\n",
+ "getField @StringValue pass\n",
+ "getField @StringValue area"
]
},
{
@@ -409,7 +289,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 9,
"metadata": {
"tags": []
},
@@ -432,7 +312,7 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 10,
"metadata": {
"tags": []
},
@@ -493,28 +373,21 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 11,
"metadata": {
+ "collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
- "outputs": [
- {
- "data": {
- "text/plain": []
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
- "setField text ChangeHandler $ do\n",
- " input <- unpack <$> getField text StringValue\n",
+ "setField @ChangeHandler text $ do\n",
+ " input <- unpack <$> getField @StringValue text\n",
" str <- case parse phoneNumber \"\" input of\n",
" Left error -> return (show error)\n",
" Right x -> return (show x)\n",
- " setField area StringValue (pack str)"
+ " setField @StringValue area (pack str)"
]
},
{
@@ -533,7 +406,7 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 12,
"metadata": {
"tags": []
},
@@ -541,7 +414,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "93ea02c6-5afc-4e10-813e-3a7d019e4688",
+ "model_id": "1574dfdc-b482-4da1-8d54-4090a0c29632",
"version_major": 2,
"version_minor": 0
}
@@ -552,208 +425,13 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "a5a7eea1-3090-4351-a021-65618ddaa5a5",
+ "model_id": "498d1b85-fca3-48a3-84aa-17822e960bf6",
"version_major": 2,
"version_minor": 0
}
},
"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"
- },
- {
- "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": [
@@ -772,13 +450,13 @@
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6db784a4-191f-4087-bb9a-0a2932eae40e",
+ "model_id": "42d26919-28c0-41b5-9a69-2c37b7fd270c",
"version_major": 2,
"version_minor": 0
}
@@ -789,104 +467,31 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6c243e81-e59c-453c-98a0-b394c43b4a93",
+ "model_id": "4e1bf52c-ad60-4280-bd94-2b38b953cf8a",
"version_major": 2,
"version_minor": 0
}
},
"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": [
"valid <- mkValid\n",
"pwd <- mkPassword\n",
"\n",
- "setField pwd ChangeHandler $ getField pwd StringValue >>= setField valid BoolValue . (\"1234\"==)\n",
+ "setField @ChangeHandler pwd $ getField @StringValue pwd >>= setField @BoolValue valid . (\"1234\"==)\n",
"\n",
"pwd\n",
"valid"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -901,7 +506,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/Examples/Widget List.ipynb b/ihaskell-display/ihaskell-widgets/Examples/Widget List.ipynb
index 845a5722..84417a94 100644
--- a/ihaskell-display/ihaskell-widgets/Examples/Widget List.ipynb
+++ b/ihaskell-display/ihaskell-widgets/Examples/Widget List.ipynb
@@ -11,15 +11,16 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 47,
"id": "db4f655b-d163-4dd5-a8cf-8a5cf0fbca48",
"metadata": {},
"outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"import Data.Text\n",
- "import IHaskell.Display.Widgets\n",
- "import IHaskell.Display.Widgets.Layout as L"
+ "import IHaskell.Display.Widgets as W\n",
+ "import IHaskell.Display.Widgets.Layout as L\n",
+ "import Data.Proxy"
]
},
{
@@ -47,22 +48,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"id": "d2954629-2d81-4817-b366-bca2e62d8d6e",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "79d4d88b-45c4-408d-840b-fc2242463b1e",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"intSlider <- mkIntSlider\n",
- "setField intSlider IntValue 7\n",
- "setField intSlider MinInt 0\n",
- "setField intSlider MaxInt 100\n",
- "setField intSlider StepInt $ Just 1\n",
- "setField intSlider Description \"Test: \"\n",
- "setField intSlider Disabled False\n",
- "setField intSlider ContinuousUpdate False\n",
- "setField intSlider Orientation HorizontalOrientation\n",
- "setField intSlider ReadOut True\n",
- "setField intSlider ReadOutFormat \"d\"\n",
+ "setField @IntValue intSlider 7\n",
+ "setField @MinInt intSlider 0\n",
+ "setField @MaxInt intSlider 100\n",
+ "setField @StepInt intSlider $ Just 1\n",
+ "setField @Description intSlider \"Test: \"\n",
+ "setField @Disabled intSlider False\n",
+ "setField @ContinuousUpdate intSlider False\n",
+ "setField @Orientation intSlider HorizontalOrientation\n",
+ "setField @ReadOut intSlider True\n",
+ "setField @ReadOutFormat intSlider \"d\"\n",
"intSlider"
]
},
@@ -77,22 +90,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"id": "6a96cd33-8007-42b1-b618-0b96bb8bbe31",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "468ae5e9-1c09-4d57-b3b7-c4f0016f8c85",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"floatSlider <- mkFloatSlider\n",
- "setField floatSlider FloatValue 7.5\n",
- "setField floatSlider MinFloat 0.0\n",
- "setField floatSlider MaxFloat 10.0\n",
- "setField floatSlider StepFloat $ Just 0.1\n",
- "setField floatSlider Description \"Test float: \"\n",
- "setField floatSlider Disabled False\n",
- "setField floatSlider ContinuousUpdate False\n",
- "setField floatSlider Orientation VerticalOrientation\n",
- "setField floatSlider ReadOut True\n",
- "setField floatSlider ReadOutFormat \".1f\"\n",
+ "setField @FloatValue floatSlider 7.5\n",
+ "setField @MinFloat floatSlider 0.0\n",
+ "setField @MaxFloat floatSlider 10.0\n",
+ "setField @StepFloat floatSlider $ Just 0.1\n",
+ "setField @Description floatSlider \"Test float: \"\n",
+ "setField @Disabled floatSlider False\n",
+ "setField @ContinuousUpdate floatSlider False\n",
+ "setField @Orientation floatSlider VerticalOrientation\n",
+ "setField @ReadOut floatSlider True\n",
+ "setField @ReadOutFormat floatSlider \".1f\"\n",
"floatSlider"
]
},
@@ -107,18 +132,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"id": "f09bec94-8bb3-45ce-99fe-a3bcb48852ec",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "45f9a996-cf10-4507-9448-0182819c720c",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"floatLogSlider <- mkFloatLogSlider\n",
- "setField floatLogSlider FloatValue 10\n",
- "setField floatLogSlider BaseFloat 10\n",
- "setField floatLogSlider MinFloat (-10)\n",
- "setField floatLogSlider MaxFloat 10\n",
- "setField floatLogSlider StepFloat $ Just 0.2\n",
- "setField floatLogSlider Description \"A log slider\"\n",
+ "setField @FloatValue floatLogSlider 10\n",
+ "setField @BaseFloat floatLogSlider 10\n",
+ "setField @MinFloat floatLogSlider (-10)\n",
+ "setField @MaxFloat floatLogSlider 10\n",
+ "setField @StepFloat floatLogSlider $ Just 0.2\n",
+ "setField @Description floatLogSlider \"A log slider\"\n",
"floatLogSlider"
]
},
@@ -133,21 +170,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"id": "7ba73761-5487-44c7-a8c2-5d315a33fa6a",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "250208f4-c592-4b9f-85a1-fc5fd301d6f6",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"intRangeSlider <- mkIntRangeSlider\n",
- "setField intRangeSlider IntPairValue (5,7)\n",
- "setField intRangeSlider MinInt 0\n",
- "setField intRangeSlider MaxInt 10\n",
- "setField intRangeSlider StepInt $ Just 1\n",
- "setField intRangeSlider Disabled False\n",
- "setField intRangeSlider ContinuousUpdate False\n",
- "setField intRangeSlider Orientation HorizontalOrientation\n",
- "setField intRangeSlider ReadOut True\n",
- "setField intRangeSlider ReadOutFormat \"d\"\n",
+ "setField @IntPairValue intRangeSlider (5,7)\n",
+ "setField @MinInt intRangeSlider 0\n",
+ "setField @MaxInt intRangeSlider 10\n",
+ "setField @StepInt intRangeSlider $ Just 1\n",
+ "setField @Disabled intRangeSlider False\n",
+ "setField @ContinuousUpdate intRangeSlider False\n",
+ "setField @Orientation intRangeSlider HorizontalOrientation\n",
+ "setField @ReadOut intRangeSlider True\n",
+ "setField @ReadOutFormat intRangeSlider \"d\"\n",
"intRangeSlider"
]
},
@@ -161,21 +210,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"id": "1098100a-c2f8-4883-a8ce-3a03560447bb",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "8649f114-34ec-4166-a9e3-77a084ddcb1d",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"floatRangeSlider <- mkFloatRangeSlider\n",
- "setField floatRangeSlider FloatPairValue (5.0,7.5)\n",
- "setField floatRangeSlider MinFloat 0\n",
- "setField floatRangeSlider MaxFloat 10\n",
- "setField floatRangeSlider StepFloat $ Just 0.1\n",
- "setField floatRangeSlider Disabled False\n",
- "setField floatRangeSlider ContinuousUpdate False\n",
- "setField floatRangeSlider Orientation HorizontalOrientation\n",
- "setField floatRangeSlider ReadOut True\n",
- "setField floatRangeSlider ReadOutFormat \".1f\"\n",
+ "setField @FloatPairValue floatRangeSlider (5.0,7.5)\n",
+ "setField @MinFloat floatRangeSlider 0\n",
+ "setField @MaxFloat floatRangeSlider 10\n",
+ "setField @StepFloat floatRangeSlider $ Just 0.1\n",
+ "setField @Disabled floatRangeSlider False\n",
+ "setField @ContinuousUpdate floatRangeSlider False\n",
+ "setField @Orientation floatRangeSlider HorizontalOrientation\n",
+ "setField @ReadOut floatRangeSlider True\n",
+ "setField @ReadOutFormat floatRangeSlider \".1f\"\n",
"floatRangeSlider"
]
},
@@ -195,30 +256,42 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"id": "1f47e516-a0df-4365-9093-a9649adbcfbb",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "945fbcd1-9195-4173-ba00-8661b18fa2df",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"intProgress <- mkIntProgress\n",
- "setField intProgress IntValue 7\n",
- "setField intProgress MinInt 0\n",
- "setField intProgress MaxInt 10\n",
- "setField intProgress Description \"Now loading\"\n",
- "setField intProgress BarStyle InfoBar\n",
+ "setField @IntValue intProgress 7\n",
+ "setField @MinInt intProgress 0\n",
+ "setField @MaxInt intProgress 10\n",
+ "setField @Description intProgress \"Now loading\"\n",
+ "setField @BarStyle intProgress InfoBar\n",
"intProgress"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"id": "eef18bbb-c96b-47f1-bdab-a12b0c66b865",
"metadata": {},
"outputs": [],
"source": [
"s <- mkProgressStyle\n",
- "setField s BarColor $ Just \"#ffff00\"\n",
- "setField intProgress Style (StyleWidget s)"
+ "setField @BarColor s $ Just \"#ffff00\"\n",
+ "setField @Style intProgress (StyleWidget s)"
]
},
{
@@ -232,18 +305,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"id": "3c09cc52-5187-4698-96f6-1c12729a7cfe",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "e3c59262-0466-41bb-9616-38906896971f",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"boundedIntText <- mkBoundedIntText\n",
- "setField boundedIntText IntValue 7\n",
- "setField boundedIntText MinInt 0\n",
- "setField boundedIntText MaxInt 10\n",
- "setField boundedIntText StepInt $ Just 1\n",
- "setField boundedIntText Description \"Text: \"\n",
- "setField boundedIntText Disabled False\n",
+ "setField @IntValue boundedIntText 7\n",
+ "setField @MinInt boundedIntText 0\n",
+ "setField @MaxInt boundedIntText 10\n",
+ "setField @StepInt boundedIntText $ Just 1\n",
+ "setField @Description boundedIntText \"Text: \"\n",
+ "setField @Disabled boundedIntText False\n",
"boundedIntText"
]
},
@@ -257,18 +342,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"id": "652ece64-05e4-484b-af80-4971ea5fa27c",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2ba6739e-d35d-4d0d-8492-3cdfc6113c4b",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"boundedFloatText <- mkBoundedFloatText\n",
- "setField boundedFloatText FloatValue 7.5\n",
- "setField boundedFloatText MinFloat 0.0\n",
- "setField boundedFloatText MaxFloat 10.0\n",
- "setField boundedFloatText StepFloat $ Just 0.1\n",
- "setField boundedFloatText Description \"Text: \"\n",
- "setField boundedFloatText Disabled False\n",
+ "setField @FloatValue boundedFloatText 7.5\n",
+ "setField @MinFloat boundedFloatText 0.0\n",
+ "setField @MaxFloat boundedFloatText 10.0\n",
+ "setField @StepFloat boundedFloatText (Just 0.1)\n",
+ "setField @Description boundedFloatText \"Text: \"\n",
+ "setField @Disabled boundedFloatText False\n",
"boundedFloatText"
]
},
@@ -282,15 +379,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"id": "9d306ca8-6abb-4644-98d8-38a11d4b5bad",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "4ba3c3f7-05ae-4e82-87e8-264d08d49e92",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"intText <- mkIntText\n",
- "setField intText IntValue 7\n",
- "setField intText Description \"Any:\"\n",
- "setField intText Disabled False\n",
+ "setField @IntValue intText 7\n",
+ "setField @Description intText \"Any:\"\n",
+ "setField @Disabled intText False\n",
"intText"
]
},
@@ -304,15 +413,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"id": "811aab8a-c6ee-41d6-b9a9-99a4d0924a93",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "fa20a112-58c1-4f3e-9e7a-ca5dfd470095",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"floatText <- mkFloatText\n",
- "setField floatText FloatValue 7.5\n",
- "setField floatText Description \"Any:\"\n",
- "setField floatText Disabled False\n",
+ "setField @FloatValue floatText 7.5\n",
+ "setField @Description floatText \"Any:\"\n",
+ "setField @Disabled floatText False\n",
"floatText"
]
},
@@ -329,19 +450,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"id": "7be1e91b-f28e-4be3-83cb-ac0954a87db8",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "0ba3caad-97b8-4287-bfd8-676c89410c7d",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"toggleButton <- mkToggleButton\n",
- "setField toggleButton BoolValue False\n",
- "setField toggleButton Description \"Click me\"\n",
- "setField toggleButton Disabled False\n",
+ "setField @BoolValue toggleButton False\n",
+ "setField @Description toggleButton \"Click me\"\n",
+ "setField @Disabled toggleButton False\n",
"-- DefaultButton | PrimaryButton | SuccessButton | INfoButton | WarningButton | DangerButton\n",
- "setField toggleButton ButtonStyle DefaultButton\n",
- "setField toggleButton Tooltip $ Just \"Description\"\n",
- "setField toggleButton Icon \"check\"\n",
+ "setField @ButtonStyleField toggleButton DefaultButton\n",
+ "setField @Tooltip toggleButton $ Just \"Description\"\n",
+ "setField @Icon toggleButton \"check\"\n",
"toggleButton"
]
},
@@ -355,16 +488,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"id": "0514c055-060d-493d-aa91-55dc00cb0d5f",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "60105b27-2524-4416-9f3b-23ed1cf7dcd1",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"checkBox <- mkCheckBox\n",
- "setField checkBox BoolValue False\n",
- "setField checkBox Description \"Check me out!\"\n",
- "setField checkBox Disabled False\n",
- "setField checkBox Indent False\n",
+ "setField @BoolValue checkBox False\n",
+ "setField @Description checkBox \"Check me out!\"\n",
+ "setField @Disabled checkBox False\n",
+ "setField @Indent checkBox False\n",
"checkBox"
]
},
@@ -379,14 +524,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"id": "606594cb-08a3-41a2-b060-9d2d0ef3f588",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ddc56e90-8284-44e6-8d05-2e8d738b53df",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"valid <- mkValid\n",
- "setField valid BoolValue False\n",
- "setField valid Description \"Valid?\"\n",
+ "setField @BoolValue valid False\n",
+ "setField @Description valid \"Valid?\"\n",
"valid"
]
},
@@ -405,16 +562,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"id": "9472cea4-69f1-409c-8244-1e79a5f56050",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7a48fe8f-a7c9-4400-bd23-1a849041a045",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"dropdown <- mkDropdown\n",
- "setField dropdown OptionsLabels [\"1\", \"2\", \"3\"]\n",
- "setField dropdown OptionalIndex $ Just 2\n",
- "setField dropdown Description \"Number:\"\n",
- "setField dropdown Disabled False\n",
+ "setField @OptionsLabels dropdown [\"1\", \"2\", \"3\"]\n",
+ "setField @OptionalIndex dropdown $ Just 2\n",
+ "setField @Description dropdown \"Number:\"\n",
+ "setField @Disabled dropdown False\n",
"dropdown"
]
},
@@ -428,16 +597,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"id": "013b11dd-f193-4011-9539-ce177c2df0e0",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b5477e5d-b3ed-48a6-9c55-75e569d0ce9c",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"radioButtons <- mkRadioButtons\n",
- "setField radioButtons OptionsLabels [\"pepperoni\", \"pineapple\", \"anchovies\"]\n",
- "setField radioButtons OptionalIndex Nothing\n",
- "setField radioButtons Description \"Topping:\"\n",
- "setField radioButtons Disabled False\n",
+ "setField @OptionsLabels radioButtons [\"pepperoni\", \"pineapple\", \"anchovies\"]\n",
+ "setField @OptionalIndex radioButtons Nothing\n",
+ "setField @Description radioButtons \"Topping:\"\n",
+ "setField @Disabled radioButtons False\n",
"radioButtons"
]
},
@@ -451,27 +632,39 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"id": "abd06526-4838-4d2e-b191-136fad9e10f5",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "bd519145-a4dc-440f-bccf-6a5465b75fbd",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"radioButtons' <- mkRadioButtons\n",
- "setField radioButtons' OptionsLabels [\n",
+ "setField @OptionsLabels radioButtons' [\n",
" \"pepperoni\",\n",
" \"pineapple\",\n",
" \"anchovies\",\n",
" \"Spam, sausage, Spam, Spam, Spam, bacon, Spam, tomato and Spam\"\n",
" ]\n",
"label <- mkLabel\n",
- "setField label StringValue \"Pizza topping with a very long label\"\n",
+ "setField @StringValue label \"Pizza topping with a very long label\"\n",
"\n",
"layout <- mkLayout\n",
- "setField layout L.Width $ Just \"max-content\"\n",
+ "setField @L.Width layout $ Just \"max-content\"\n",
"\n",
"box <- mkBox\n",
- "setField box Children [ChildWidget label, ChildWidget radioButtons']\n",
- "setField box Layout layout\n",
+ "setField @Children box [ChildWidget label, ChildWidget radioButtons']\n",
+ "setField @W.Layout box layout\n",
"box"
]
},
@@ -485,16 +678,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"id": "bcd0e446-cb09-49a9-b41c-08cf81094bfc",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "3f14b524-41af-4e19-961f-1461ef77cbc9",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"select <- mkSelect\n",
- "setField select OptionsLabels [\"Linux\", \"Windows\", \"OSX\"]\n",
- "setField select OptionalIndex $ Just 0\n",
- "setField select Description \"OS:\"\n",
- "setField select Disabled False\n",
+ "setField @OptionsLabels select [\"Linux\", \"Windows\", \"OSX\"]\n",
+ "setField @OptionalIndex select $ Just 0\n",
+ "setField @Description select \"OS:\"\n",
+ "setField @Disabled select False\n",
"select"
]
},
@@ -508,19 +713,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"id": "4a59fe64-0b50-49d8-897b-b96a56bc5a43",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "9939d223-0b38-416a-9eb3-68ccbb0e7ae6",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"selectionSlider <- mkSelectionSlider\n",
- "setField selectionSlider OptionsLabels [\"Scrambled\", \"Sunny side up\", \"Poached\", \"Over easy\"]\n",
- "setField selectionSlider Index 1\n",
- "setField selectionSlider Description \"I like my eggs...\"\n",
- "setField selectionSlider Disabled False\n",
- "setField selectionSlider ContinuousUpdate False\n",
- "setField selectionSlider Orientation HorizontalOrientation\n",
- "setField selectionSlider ReadOut True\n",
+ "setField @OptionsLabels selectionSlider [\"Scrambled\", \"Sunny side up\", \"Poached\", \"Over easy\"]\n",
+ "setField @Index selectionSlider 1\n",
+ "setField @Description selectionSlider \"I like my eggs...\"\n",
+ "setField @Disabled selectionSlider False\n",
+ "setField @ContinuousUpdate selectionSlider False\n",
+ "setField @Orientation selectionSlider HorizontalOrientation\n",
+ "setField @ReadOut selectionSlider True\n",
"selectionSlider"
]
},
@@ -540,11 +757,11 @@
"outputs": [],
"source": [
"selectionRangeSlider <- mkSelectionRangeSlider\n",
- "setField selectionRangeSlider OptionsLabels [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n",
- "setField selectionRangeSlider Indices [0,4]\n",
- "setField selectionRangeSlider Description \"When is the shop open?\"\n",
- "setField selectionRangeSlider Disabled False\n",
- "selectionRangeSlider"
+ "setField @OptionsLabels selectionRangeSlider [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n",
+ "setField @Indices selectionRangeSlider [0, 4]\n",
+ "setField @Description selectionRangeSlider \"When is the shop open?\"\n",
+ "setField @Disabled selectionRangeSlider False\n",
+ "selectionRangeSlider\n"
]
},
{
@@ -557,18 +774,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"id": "0423d92a-3d9b-4f82-aeed-c869617817b3",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "acefe3fb-800c-4f67-aad1-63928afb9923",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"toggleButtons <- mkToggleButtons\n",
- "setField toggleButtons OptionsLabels [\"Slow\", \"Regular\", \"Fast\"]\n",
- "setField toggleButtons Description \"Speed:\"\n",
- "setField toggleButtons Disabled False\n",
- "-- PrimaryButton | SuccessButton | InfoButton | WarningButton | DangerButton | DefaultButton\n",
- "setField toggleButtons ButtonStyle DefaultButton\n",
- "setField toggleButtons Tooltips [\"Description of slow\", \"Description of regular\", \"Description of fast\"]\n",
+ "setField @OptionsLabels toggleButtons [\"Slow\", \"Regular\", \"Fast\"]\n",
+ "setField @Description toggleButtons \"Speed:\"\n",
+ "setField @Disabled toggleButtons False\n",
+ "setField @ButtonStyleField toggleButtons DefaultButton\n",
+ "setField @Tooltips toggleButtons [\"Description of slow\", \"Description of regular\", \"Description of fast\"]\n",
"toggleButtons"
]
},
@@ -583,16 +811,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"id": "8332e274-bb0d-4be2-b9b4-a08c633f6a4b",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "d1a1d8fd-dc05-4de5-817a-c56112df19b9",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"selectMultiple <- mkSelectMultiple\n",
- "setField selectMultiple OptionsLabels [\"Apples\", \"Oranges\", \"Pears\"]\n",
- "setField selectMultiple Indices [1]\n",
- "setField selectMultiple Description \"Fruits\"\n",
- "setField selectMultiple Disabled False\n",
+ "setField @OptionsLabels selectMultiple [\"Apples\", \"Oranges\", \"Pears\"]\n",
+ "setField @Indices selectMultiple [1]\n",
+ "setField @Description selectMultiple \"Fruits\"\n",
+ "setField @Disabled selectMultiple False\n",
"selectMultiple"
]
},
@@ -612,16 +852,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"id": "ce3ba3b3-cfea-41f8-ab61-a58b7db1d322",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "188228cc-1ed5-4290-a8db-0e5f958bdf4e",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"text <- mkText\n",
- "setField text StringValue \"Hello World!\"\n",
- "setField text Placeholder \"Type something\"\n",
- "setField text Description \"String:\"\n",
- "setField text Disabled False\n",
+ "setField @StringValue text \"Hello World!\"\n",
+ "setField @Placeholder text \"Type something\"\n",
+ "setField @Description text \"String:\"\n",
+ "setField @Disabled text False\n",
"text"
]
},
@@ -635,16 +887,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"id": "0528b6ca-caac-4895-a071-6bb2d3a1838d",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "e216aeb9-ce61-4766-a2df-09d86a584085",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"textarea <- mkTextArea\n",
- "setField textarea StringValue \"Hello World!\"\n",
- "setField textarea Placeholder \"Type something\"\n",
- "setField textarea Description \"Long string:\"\n",
- "setField textarea Disabled False\n",
+ "setField @StringValue textarea \"Hello World!\"\n",
+ "setField @Placeholder textarea \"Type something\"\n",
+ "setField @Description textarea \"Long string:\"\n",
+ "setField @Disabled textarea False\n",
"textarea"
]
},
@@ -658,17 +922,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"id": "6872c8b4-59e9-4eb6-9d32-9526f20940b2",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "bb2d88f5-880c-4aed-9fa4-8f0c0cf60865",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"combobox <- mkCombobox\n",
- "setField combobox Placeholder \"Choose Someone\"\n",
- "setField combobox Options [\"Paul\", \"John\", \"George\", \"Ringo\"]\n",
- "setField combobox Description \"Combobox:\"\n",
- "setField combobox EnsureOption True\n",
- "setField combobox Disabled False\n",
+ "setField @Placeholder combobox \"Choose Someone\"\n",
+ "setField @Options combobox [\"Paul\", \"John\", \"George\", \"Ringo\"]\n",
+ "setField @Description combobox \"Combobox:\"\n",
+ "setField @EnsureOption combobox True\n",
+ "setField @Disabled combobox False\n",
"combobox"
]
},
@@ -686,16 +962,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"id": "56554ed4-9003-4af0-a407-9ccc6dbb60c5",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "266af757-8d05-49bc-a66f-f3278386b653",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"password <- mkPassword\n",
- "setField password StringValue \"Password\"\n",
- "setField password Placeholder \"Enter password\"\n",
- "setField password Description \"Password:\"\n",
- "setField password Disabled False\n",
+ "setField @StringValue password \"Password\"\n",
+ "setField @Placeholder password \"Enter password\"\n",
+ "setField @Description password \"Password:\"\n",
+ "setField @Disabled password False\n",
"password"
]
},
@@ -710,18 +998,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"id": "b8c01e21-1438-47c5-ab9f-f70b08040f85",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "5ee8d7d6-9776-4a30-8fa8-942e18b0fdf5",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"label <- mkLabel\n",
- "setField label StringValue \"The $m$ in $E=mc^2$:\"\n",
+ "setField @StringValue label \"The $m$ in $E=mc^2$:\"\n",
"\n",
"floatSlider <- mkFloatSlider\n",
"\n",
"hbox <- mkHBox\n",
- "setField hbox Children [ChildWidget label, ChildWidget floatSlider]\n",
+ "setField @Children hbox [ChildWidget label, ChildWidget floatSlider]\n",
"hbox"
]
},
@@ -735,15 +1035,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 40,
"id": "42d32123-22a5-4322-a8e5-efe1d2bc3deb",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "716c5c49-8b7e-428e-8b95-d24484d3ab0f",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"html <- mkHTML\n",
- "setField html StringValue \"Hello World!\"\n",
- "setField html Placeholder \"Some HTML\"\n",
- "setField html Description \"Some HTML\"\n",
+ "setField @StringValue html \"Hello World!\"\n",
+ "setField @Placeholder html \"Some HTML\"\n",
+ "setField @Description html \"Some HTML\"\n",
"html"
]
},
@@ -758,16 +1070,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 41,
"id": "7c277fa9-f8be-4f7b-bffe-26bc74298572",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "d247a274-10d2-4036-9eec-4109eb7050a6",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"htmlMath <- mkHTMLMath\n",
"-- Remember to escape the \\ with \\\\\n",
- "setField htmlMath StringValue \"Some math and HTML: $x^2$ and $$\\\\frac{x+1}{x-1}$$\"\n",
- "setField htmlMath Placeholder \"Some HTML\"\n",
- "setField htmlMath Description \"Some HTML\"\n",
+ "setField @StringValue htmlMath \"Some math and HTML: $x^2$ and $$\\\\frac{x+1}{x-1}$$\"\n",
+ "setField @Placeholder htmlMath \"Some HTML\"\n",
+ "setField @Description htmlMath \"Some HTML\"\n",
"htmlMath"
]
},
@@ -781,15 +1105,27 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"id": "01eff752-f657-4a11-ad1f-8daa4bff927e",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "782c7f34-56a5-4308-abcf-42ef6236534c",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"image <- mkImage\n",
- "setField image BSValue \"https://imgs.xkcd.com/comics/haskell.png\"\n",
+ "setField @BSValue image \"https://imgs.xkcd.com/comics/haskell.png\"\n",
"-- PNG | SVG | JPG | IURL\n",
- "setField image ImageFormat IURL\n",
+ "setField @ImageFormat image IURL\n",
"image"
]
},
@@ -803,18 +1139,55 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 44,
"id": "bf84c8f3-75b2-468c-a4f3-53358bd3241f",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "ViewModule ::: Text\n",
+ "ViewModuleVersion ::: Text\n",
+ "ModelModule ::: Text\n",
+ "ModelModuleVersion ::: Text\n",
+ "ModelName ::: Text\n",
+ "ViewName ::: Text\n",
+ "DOMClasses ::: [Text]\n",
+ "Tabbable ::: Maybe Bool\n",
+ "Tooltip ::: Maybe Text\n",
+ "Layout ::: IPythonWidget LayoutType\n",
+ "DisplayHandler ::: IO ()\n",
+ "Description ::: Text\n",
+ "DescriptionAllowHtml ::: Maybe Bool\n",
+ "Style ::: StyleWidget\n",
+ "Disabled ::: Bool\n",
+ "Icon ::: Text\n",
+ "ButtonStyleField ::: ButtonStyleValue\n",
+ "ClickHandler ::: IO ()"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c02b5802-3336-45ae-bc5f-308fec0ac4e0",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"button <- mkButton\n",
- "setField button Description \"Click me\"\n",
- "setField button Disabled False\n",
- "-- PrimaryButton | SuccessButton | InfoButton | WarningButton | DangerButton | DefaultButton\n",
- "setField button ButtonStyle DefaultButton\n",
- "setField button Tooltip $ Just \"Click me\"\n",
- "setField button Icon \"mouse\"\n",
+ "setField @Description button \"Click me\"\n",
+ "setField @Disabled button False\n",
+ "setField @ButtonStyleField button DefaultButton\n",
+ "setField @Tooltip button (Just \"Click me\")\n",
+ "setField @Icon button \"mouse\"\n",
"properties button\n",
"button"
]
@@ -837,22 +1210,56 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 48,
"id": "acdc051c-4c72-4fda-a29e-286ec8aa86f9",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "c2410530-615c-4acf-bfa2-3c810716c1e3",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7e72453c-84a7-49db-a17b-c821551a0816",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "4fc1ead3-53ce-43fd-b9c2-63103ce5a78f",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"play <- mkPlay\n",
- "setField play IntValue 50\n",
- "setField play MinInt 0\n",
- "setField play MaxInt 100\n",
- "setField play StepInt $ Just 1\n",
- "setField play Interval 500\n",
- "setField play Description \"Press play\"\n",
- "setField play Disabled False\n",
+ "setField @IntValue play 50\n",
+ "setField @MinInt play 0\n",
+ "setField @MaxInt play 100\n",
+ "setField @StepInt play (Just 1)\n",
+ "setField @Interval play 500\n",
+ "setField @Description play \"Press play\"\n",
+ "setField @Disabled play False\n",
"\n",
"slider <- mkIntSlider\n",
- "jslink (WidgetFieldPair play IntValue) (WidgetFieldPair slider IntValue)\n",
+ "jslink (WidgetFieldPair play (Proxy @IntValue)) (WidgetFieldPair slider (Proxy @IntValue))\n",
"\n",
"play\n",
"slider"
@@ -869,14 +1276,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 49,
"id": "1572fa8f-992a-4bb2-976a-26c7db3599c8",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "ae1acc56-058f-4b93-b766-4e5d51efb3b5",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"datePicker <- mkDatePicker\n",
- "setField datePicker Description \"Pick a date\"\n",
- "setField datePicker Disabled False\n",
+ "setField @Description datePicker \"Pick a date\"\n",
+ "setField @Disabled datePicker False\n",
"datePicker"
]
},
@@ -890,16 +1309,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 50,
"id": "8d354b46-707d-4b67-add3-04c1e906ce31",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "96d92be0-66d1-4b09-9d13-ef120354841a",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"colorPicker <- mkColorPicker\n",
- "setField colorPicker Concise False\n",
- "setField colorPicker Description \"Pick a color\"\n",
- "setField colorPicker StringValue \"Blue\"\n",
- "setField colorPicker Disabled False\n",
+ "setField @Concise colorPicker False\n",
+ "setField @Description colorPicker \"Pick a color\"\n",
+ "setField @StringValue colorPicker \"Blue\"\n",
+ "setField @Disabled colorPicker False\n",
"colorPicker"
]
},
@@ -914,13 +1345,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 51,
"id": "5b204580-a4ab-4b48-b34e-2bcb5abae9ad",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "97cbe9db-15a8-4be6-8660-1adf47d0d544",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"controller <- mkController\n",
- "setField controller Index 0\n",
+ "setField @Index controller 0\n",
"controller"
]
},
@@ -938,18 +1381,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 52,
"id": "262e9246-0ce1-43dc-9ec8-a5b621957355",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "a5529dc4-1eb2-47e7-b0c9-70a547288112",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"labels <- flip mapM [1..4] $ \\i->do\n",
" l <- mkLabel\n",
- " setField l StringValue $ pack $ (\"Label #\" ++ show i)\n",
+ " setField @StringValue l $ pack $ (\"Label #\" ++ show i)\n",
" return $ ChildWidget l\n",
"\n",
"box <- mkBox\n",
- "setField box Children labels\n",
+ "setField @Children box labels\n",
"box"
]
},
@@ -963,13 +1418,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 54,
"id": "db37b5ce-3154-4194-8241-a2b15e41fdcf",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "7c56564e-74f5-4bef-be16-02a9e31f9845",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"hbox <- mkHBox\n",
- "setField hbox Children labels\n",
+ "setField @Children hbox labels\n",
"hbox"
]
},
@@ -983,13 +1450,25 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 55,
"id": "97500421-d638-4123-88c0-0fda9cd307b2",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "a733b6f5-5b13-43ac-bf0e-574c067028c1",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"vbox <- mkVBox\n",
- "setField vbox Children labels\n",
+ "setField @Children vbox labels\n",
"vbox"
]
},
@@ -1005,22 +1484,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 57,
"id": "5a922615-b529-41ef-9af3-346b909f18bb",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "2b5cc805-fa7f-4b54-ad73-99bb30091fbd",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"labels <- flip mapM [1..8] $ \\i->do\n",
" l <- mkLabel\n",
- " setField l StringValue $ pack $ (\"Label #\" ++ show i)\n",
+ " setField @StringValue l $ pack $ (\"Label #\" ++ show i)\n",
" return $ ChildWidget l\n",
" \n",
"layout <- mkLayout\n",
- "setField layout L.GridTemplateColumns $ Just \"repeat(3, 10em)\"\n",
+ "setField @L.GridTemplateColumns layout $ Just \"repeat(3, 10em)\"\n",
" \n",
"gridBox <- mkGridBox\n",
- "setField gridBox Children labels\n",
- "setField gridBox Layout layout\n",
+ "setField @Children gridBox labels\n",
+ "setField @W.Layout gridBox layout\n",
"gridBox"
]
},
@@ -1038,16 +1529,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 58,
"id": "6e0c7074-d20a-44ae-8ea9-ee7aeacf6f27",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "611adc68-e5f8-4371-9ebf-57e2bef27f5c",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"accordion <- mkAccordion\n",
"slider <- mkIntSlider\n",
"text <- mkText\n",
- "setField accordion Children [ChildWidget slider, ChildWidget text]\n",
- "setField accordion Titles [\"Slider\", \"Text\"]\n",
+ "setField @Children accordion [ChildWidget slider, ChildWidget text]\n",
+ "setField @Titles accordion [\"Slider\", \"Text\"]\n",
"accordion"
]
},
@@ -1061,23 +1564,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 59,
"id": "f006c848-a5bb-4956-98c9-d68ec87ff703",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "6f1e0606-dc7a-4c2d-93d9-bcf58242219f",
+ "version_major": 2,
+ "version_minor": 0
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
"source": [
"tabs <- mkTab\n",
"\n",
"texts <- flip mapM [0..5] $ \\i->do\n",
" t <- mkText\n",
- " setField t StringValue $ pack $ (\"P\" ++ show i)\n",
+ " setField @StringValue t $ pack $ (\"P\" ++ show i)\n",
" return $ ChildWidget t\n",
"\n",
- "setField tabs Children texts\n",
- "setField tabs Titles [pack $ show i | i <- [0..5]]\n",
- "setField tabs SelectedIndex $ Just 2\n",
+ "setField @Children tabs texts\n",
+ "setField @Titles tabs [pack $ show i | i <- [0..5]]\n",
+ "setField @SelectedIndex tabs $ Just 2\n",
"tabs"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "aee75c09-81c5-46a5-a604-f2381485b4ec",
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
@@ -1092,7 +1615,7 @@
"mimetype": "text/x-haskell",
"name": "haskell",
"pygments_lexer": "Haskell",
- "version": "8.10.4"
+ "version": "9.8.2"
}
},
"nbformat": 4,
diff --git a/ihaskell-display/ihaskell-widgets/README.md b/ihaskell-display/ihaskell-widgets/README.md
index 83a937b0..82053580 100644
--- a/ihaskell-display/ihaskell-widgets/README.md
+++ b/ihaskell-display/ihaskell-widgets/README.md
@@ -32,9 +32,9 @@ dwelling into the deeps of the project
### Add a new attribute
If you want to add a new attribute you'll have to:
-1. Create a new singleton in [Singletons.hs](./Singletons.hs) inside the type `data Field`.
-2. Write the serialization key of the field as specified in the model (see [MsgSpec.md](./MsgSpec.md)) inside the `toKey` function at [Singletons.hs](./Singletons.hs)
-3. Because we use the `singletons-th` library, you have to define an alias for the attribute at [Common.hs](./Common.hs) to be able to use it at run-time more easily.
+1. Create a new data type in [Singletons.hs](./Singletons.hs).
+2. Write the serialization key of the field as specified in the model (see [MsgSpec.md](./MsgSpec.md)) inside the `ToKey` class at [Singletons.hs](./Singletons.hs)
+3. Fields that would benefit from helpers or enumerations can be handled in [Common.hs](./Common.hs).
4. Now you have to specify the type of the field. Edit the type family `Fieldtype` at [Types.hs](./Types.hs)
### Add an attribute to a widget
@@ -65,7 +65,7 @@ You probably got this error when trying to use setField like this:
'[]
(Data.Vinyl.TypeLevel.RIndex 'ihaskell-widgets-0.3.0.0:IHaskell.Display.Widgets.Singletons.Index '[]))
arising from a use of ‘setField’
- • In the expression: setField select Index 0
+ • In the expression: setField @Index select 0
In an equation for ‘it’: it = setField select Index 0
```
@@ -82,4 +82,4 @@ If you get an error like this, you probably forgot to put the field name in the
In the expression: setField selectMultiple ["Apples", "Oranges", "Pears"]
In an equation for ‘it’: it = setField selectMultiple ["Apples", "Oranges", "Pears"]
• Relevant bindings include it :: ihaskell-widgets-0.3.0.0:IHaskell.Display.Widgets.Types.FieldType f -> IO () (bound at :1:1)
-```
\ No newline at end of file
+```
diff --git a/ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal b/ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
index 3e5ef17f..0d7d9260 100644
--- a/ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
+++ b/ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
@@ -61,6 +61,11 @@ library
exposed-modules: IHaskell.Display.Widgets
IHaskell.Display.Widgets.Interactive
IHaskell.Display.Widgets.Layout
+ IHaskell.Display.Widgets.Layout.Common
+ IHaskell.Display.Widgets.Layout.LayoutWidget
+ IHaskell.Display.Widgets.Layout.Types
+ IHaskell.Display.Widgets.Types
+ IHaskell.Display.Widgets.Common
-- Modules included in this library but not exported.
other-modules: IHaskell.Display.Widgets.Button
@@ -115,13 +120,6 @@ library
IHaskell.Display.Widgets.Style.ProgressStyle
IHaskell.Display.Widgets.Style.SliderStyle
IHaskell.Display.Widgets.Style.ToggleButtonsStyle
-
- IHaskell.Display.Widgets.Layout.Common
- IHaskell.Display.Widgets.Layout.LayoutWidget
- IHaskell.Display.Widgets.Layout.Types
-
- IHaskell.Display.Widgets.Types
- IHaskell.Display.Widgets.Common
IHaskell.Display.Widgets.Singletons
-- LANGUAGE extensions used by modules in this package.
@@ -140,13 +138,6 @@ library
, unix -any
, ihaskell >= 0.6.4.1
- -- The singletons package version is locked to the compiler
- -- so let cabal choose the right one.
- , singletons -any
-
- if impl (ghc >= 9.0)
- build-depends: singletons-base -any
-
-- Directories containing source files.
hs-source-dirs: src
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs
index 54c9993f..4a9bd3a7 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/CheckBox.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'CheckBox' represents a Checkbox widget from IPython.html.widgets.
-type CheckBox = IPythonWidget 'CheckBoxType
+type CheckBox = IPythonWidget CheckBoxType
-- | Create a new output widget
mkCheckBox :: IO CheckBox
@@ -41,7 +42,7 @@ mkCheckBox = do
dstyle <- mkDescriptionStyle
let boolAttrs = defaultBoolWidget "CheckboxView" "CheckboxModel" layout $ StyleWidget dstyle
- checkBoxAttrs = (Indent =:: True)
+ checkBoxAttrs = (F @Indent =:: True)
:& RNil
widgetState = WidgetState $ boolAttrs <+> checkBoxAttrs
@@ -60,6 +61,6 @@ instance IHaskellWidget CheckBox where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Bool value) -> do
- void $ setField' widget BoolValue value
+ void $ setField' @BoolValue widget value
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs
index 02ce595c..1dde76a6 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/ToggleButton.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'ToggleButton' represents a ToggleButton widget from IPython.html.widgets.
-type ToggleButton = IPythonWidget 'ToggleButtonType
+type ToggleButton = IPythonWidget ToggleButtonType
-- | Create a new output widget
mkToggleButton :: IO ToggleButton
@@ -41,8 +42,8 @@ mkToggleButton = do
dstyle <- mkDescriptionStyle
let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel" layout $ StyleWidget dstyle
- toggleState = (Icon =:: "")
- :& (ButtonStyle =:: DefaultButton)
+ toggleState = (F @Icon =:: "")
+ :& (F @ButtonStyleField =:: DefaultButton)
:& RNil
widgetState = WidgetState (boolState <+> toggleState)
@@ -61,6 +62,6 @@ instance IHaskellWidget ToggleButton where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Bool value) -> do
- void $ setField' widget BoolValue value
+ void $ setField' @BoolValue widget value
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs
index e801de29..d435dea2 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'ValidWidget' represents a Valid widget from IPython.html.widgets.
-type ValidWidget = IPythonWidget 'ValidType
+type ValidWidget = IPythonWidget ValidType
-- | Create a new output widget
mkValid :: IO ValidWidget
@@ -40,7 +41,7 @@ mkValid = do
dstyle <- mkDescriptionStyle
let boolState = defaultBoolWidget "ValidView" "ValidModel" layout $ StyleWidget dstyle
- validState = (ReadOutMsg =:: "") :& RNil
+ validState = (F @ReadOutMsg =:: "") :& RNil
widgetState = WidgetState $ boolState <+> validState
stateIO <- newIORef widgetState
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs
index bdd4a56b..00126f63 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Box.hs
@@ -26,7 +26,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'Box' represents a Box widget from IPython.html.widgets.
-type Box = IPythonWidget 'BoxType
+type Box = IPythonWidget BoxType
-- | Create a new box
mkBox :: IO Box
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/GridBox.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/GridBox.hs
index 0a61fe4f..9837a8b3 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/GridBox.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/GridBox.hs
@@ -26,7 +26,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'GridBox' represents a GridBox widget from IPython.html.widgets.
-type GridBox = IPythonWidget 'GridBoxType
+type GridBox = IPythonWidget GridBoxType
-- | Create a new GridBox
mkGridBox :: IO GridBox
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/HBox.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/HBox.hs
index 7a5475e7..ee6f8cb4 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/HBox.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/HBox.hs
@@ -26,7 +26,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'HBox' represents a HBox widget from IPython.html.widgets.
-type HBox = IPythonWidget 'HBoxType
+type HBox = IPythonWidget HBoxType
-- | Create a new HBox
mkHBox :: IO HBox
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs
index d0318697..cf83521f 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'Accordion' represents a Accordion widget from IPython.html.widgets.
-type Accordion = IPythonWidget 'AccordionType
+type Accordion = IPythonWidget AccordionType
-- | Create a new box
mkAccordion :: IO Accordion
@@ -55,9 +56,9 @@ instance IHaskellWidget Accordion where
comm widget val _ =
case nestedObjectLookup val ["state", "selected_index"] of
Just (Number num) -> do
- void $ setField' widget SelectedIndex $ Just (Sci.coefficient num)
+ void $ setField' @SelectedIndex widget $ Just (Sci.coefficient num)
triggerChange widget
Just Null -> do
- void $ setField' widget SelectedIndex Nothing
+ void $ setField' @SelectedIndex widget Nothing
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs
index 4e81c9fe..cc72245d 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'TabWidget' represents a Tab widget from IPython.html.widgets.
-type TabWidget = IPythonWidget 'TabType
+type TabWidget = IPythonWidget TabType
-- | Create a new box
mkTab :: IO TabWidget
@@ -56,9 +57,9 @@ instance IHaskellWidget TabWidget where
comm widget val _ =
case nestedObjectLookup val ["state", "selected_index"] of
Just (Number num) -> do
- void $ setField' widget SelectedIndex $ Just (Sci.coefficient num)
+ void $ setField' @SelectedIndex widget $ Just (Sci.coefficient num)
triggerChange widget
Just Null -> do
- void $ setField' widget SelectedIndex Nothing
+ void $ setField' @SelectedIndex widget Nothing
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/VBox.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/VBox.hs
index 623a3988..29f45ab8 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/VBox.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/VBox.hs
@@ -26,7 +26,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'VBox' represents a VBox widget from IPython.html.widgets.
-type VBox = IPythonWidget 'VBoxType
+type VBox = IPythonWidget VBoxType
-- | Create a new VBox
mkVBox :: IO VBox
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs
index 94c8daca..80e13409 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Button.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Style.ButtonStyle
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | A 'Button' represents a Button from IPython.html.widgets.
-type Button = IPythonWidget 'ButtonType
+type Button = IPythonWidget ButtonType
-- | Create a new button
mkButton :: IO Button
@@ -40,10 +41,10 @@ mkButton = do
btnstyle <- mkButtonStyle
let ddw = defaultDescriptionWidget "ButtonView" "ButtonModel" layout $ StyleWidget btnstyle
- but = (Disabled =:: False)
- :& (Icon =:: "")
- :& (ButtonStyle =:: DefaultButton)
- :& (ClickHandler =:: return ())
+ but = (F @Disabled =:: False)
+ :& (F @Icon =:: "")
+ :& (F @ButtonStyleField =:: DefaultButton)
+ :& (F @ClickHandler =:: return ())
:& RNil
buttonState = WidgetState (ddw <+> but)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs
index 1f0f55d7..cbc36bc5 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'ColorPicker' represents a ColorPicker from IPython.html.widgets.
-type ColorPicker = IPythonWidget 'ColorPickerType
+type ColorPicker = IPythonWidget ColorPickerType
-- | Create a new ColorPicker
mkColorPicker :: IO ColorPicker
@@ -40,10 +41,10 @@ mkColorPicker = do
dstyle <- mkDescriptionStyle
let ddw = defaultDescriptionWidget "ColorPickerView" "ColorPickerModel" layout $ StyleWidget dstyle
- color = (StringValue =:: "black")
- :& (Concise =:: False)
- :& (Disabled =:: False)
- :& (ChangeHandler =:: return ())
+ color = (F @StringValue =:: "black")
+ :& (F @Concise =:: False)
+ :& (F @Disabled =:: False)
+ :& (F @ChangeHandler =:: return ())
:& RNil
colorPickerState = WidgetState (ddw <+> color)
@@ -62,6 +63,6 @@ instance IHaskellWidget ColorPicker where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just o -> case fromJSON o of
- Success (String color) -> setField' widget StringValue color >> triggerChange widget
+ Success (String color) -> setField' @StringValue widget color >> triggerChange widget
_ -> pure ()
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
index d745f8bb..08aa1718 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
@@ -13,7 +13,10 @@
{-# OPTIONS_GHC -fno-warn-missing-pattern-synonym-signatures #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-module IHaskell.Display.Widgets.Common where
+module IHaskell.Display.Widgets.Common (
+ module IHaskell.Display.Widgets.Common,
+ module IHaskell.Display.Widgets.Singletons
+ ) where
import Data.Aeson
import Data.Aeson.Types (emptyObject)
@@ -24,6 +27,7 @@ import IHaskell.Display (IHaskellWidget)
import IHaskell.Eval.Widgets (widgetSendClose)
import qualified IHaskell.Display.Widgets.Singletons as S
+import IHaskell.Display.Widgets.Singletons
#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap as KeyMap
@@ -32,201 +36,6 @@ import qualified Data.Aeson.Key as Key
import Data.HashMap.Strict as HM
#endif
--- | The view module string
-pattern ViewModule = S.SViewModule
--- | The view module version
-pattern ViewModuleVersion = S.SViewModuleVersion
--- | The view name
-pattern ViewName = S.SViewName
--- | The model module string
-pattern ModelModule = S.SModelModule
--- | The model module version
-pattern ModelModuleVersion = S.SModelModuleVersion
--- | The model name
-pattern ModelName = S.SModelName
--- | A method to be called on display
-pattern DisplayHandler = S.SDisplayHandler
--- | CSS classes applied to widget DOM element
-pattern DOMClasses = S.SDOMClasses
--- | Reference to a Layout widget
-pattern Layout = S.SLayout
--- | Width of the video/image in pixels
-pattern Width = S.SWidth
--- | Height of the video/image in pixels
-pattern Height = S.SHeight
--- | Description of the control
-pattern Description = S.SDescription
--- | Allow html in description
-pattern DescriptionAllowHtml = S.SDescriptionAllowHtml
--- | Method to be called on click
-pattern ClickHandler = S.SClickHandler
--- | Method to be called on submit
-pattern SubmitHandler = S.SSubmitHandler
--- | Whether the widget appears as disabled on the frontend
-pattern Disabled = S.SDisabled
--- | The value of the widget, of type string
-pattern StringValue = S.SStringValue
--- | Placeholder text to display if nothing has been typed yet
-pattern Placeholder = S.SPlaceholder
--- | Tooltip for the description
-pattern Tooltip = S.STooltip
--- | Is the widget tabbable?
-pattern Tabbable = S.STabbable
--- | The font-awesome icon without the fa-
-pattern Icon = S.SIcon
--- | Predefined styling for the button
-pattern ButtonStyle = S.SButtonStyle
--- | Value of the widget of type bytestring
-pattern BSValue = S.SBSValue
--- | The format of the image
-pattern ImageFormat = S.SImageFormat
--- | The value of the widget of type bool
-pattern BoolValue = S.SBoolValue
--- | The labels for the options
-pattern OptionsLabels = S.SOptionsLabels
--- | Selected index, can be Nothing
-pattern OptionalIndex = S.SOptionalIndex
--- | The index of the controller
-pattern Index = S.SIndex
--- | Method to be called when something is chosen
-pattern SelectionHandler = S.SSelectionHandler
--- | Tooltips for each button
-pattern Tooltips = S.STooltips
--- | Icons names for each button (FontAwesome names without the fa- prefix)
-pattern Icons = S.SIcons
--- | Selected indices
-pattern Indices = S.SIndices
--- | The value of the widget of type int
-pattern IntValue = S.SIntValue
--- | Minimum step to increment the value
-pattern StepInt = S.SStepInt
--- | Max value
-pattern MaxInt = S.SMaxInt
--- | Min value
-pattern MinInt = S.SMinInt
--- | The value of the widget as an int pair
-pattern IntPairValue = S.SIntPairValue
--- | Min value on a range widget
-pattern LowerInt = S.SLowerInt
--- | Max value on a range widget
-pattern UpperInt = S.SUpperInt
--- | Value of the widget (float)
-pattern FloatValue = S.SFloatValue
--- | Minimum step to increment the value
-pattern StepFloat = S.SStepFloat
--- | Max value
-pattern MaxFloat = S.SMaxFloat
--- | Min value
-pattern MinFloat = S.SMinFloat
--- | Value of the widget as a float pair
-pattern FloatPairValue = S.SFloatPairValue
--- | Min value of a range widget
-pattern LowerFloat = S.SLowerFloat
--- | Max value of a range widget
-pattern UpperFloat = S.SUpperFloat
--- | Orientation of the widget
-pattern Orientation = S.SOrientation
--- | The logarithmic base of the widget
-pattern BaseFloat = S.SBaseFloat
--- | Whether to display the current value of the widget next to it
-pattern ReadOut = S.SReadOut
--- | The format of the readout
-pattern ReadOutFormat = S.SReadOutFormat
--- | Use a predefined styling for the bar
-pattern BarStyle = S.SBarStyle
--- | A method called when the value changes in the fronted
-pattern ChangeHandler = S.SChangeHandler
--- | List of widget children
-pattern Children = S.SChildren
--- | Use a predefined styling for the box
-pattern BoxStyle = S.SBoxStyle
--- | Titles of the pages
-pattern Titles = S.STitles
--- | The index of the selected page. Is nothing if no widgets are selected.
-pattern SelectedIndex = S.SSelectedIndex
--- | Message displayed when the value is false
-pattern ReadOutMsg = S.SReadOutMsg
--- | Indent the control to align with other controls with a description
-pattern Indent = S.SIndent
--- | Update the value as the user types. If false, update on submission.
-pattern ContinuousUpdate = S.SContinuousUpdate
--- | The number of rows to display
-pattern Rows = S.SRows
--- | The format of the audio
-pattern AudioFormat = S.SAudioFormat
--- | The format of the image
-pattern VideoFormat = S.SVideoFormat
--- | When true, the video starts on display
-pattern AutoPlay = S.SAutoPlay
--- | When true, the video starts from the beginning after finishing
-pattern Loop = S.SLoop
--- | Specifies that video controls should be displayed
-pattern Controls = S.SControls
--- | Dropdown options for the combobox
-pattern Options = S.SOptions
--- | If set, ensure the value is in options
-pattern EnsureOption = S.SEnsureOption
--- | Whether the control is currently playing
-pattern Playing = S.SPlaying
--- | Whether the control will repeat in a continuous loop
-pattern Repeat = S.SRepeat
--- | The maximum interval for the play control
-pattern Interval = S.SInterval
--- | Show the repeat toggle button on the widget
-pattern ShowRepeat = S.SShowRepeat
--- | Display the short version of the selector
-pattern Concise = S.SConcise
--- | The value of the widget in date format
-pattern DateValue = S.SDateValue
--- | Whether the button is pressed
-pattern Pressed = S.SPressed
--- | The name of the controller
-pattern Name = S.SName
--- | The name of the control mapping
-pattern Mapping = S.SMapping
--- | Whether the gamepad is connected
-pattern Connected = S.SConnected
--- | The last time the data from this gamepad was updated
-pattern Timestamp = S.STimestamp
--- | The button widgets on the gamepad
-pattern Buttons = S.SButtons
--- | The axes on the gamepad
-pattern Axes = S.SAxes
--- | Color of the button
-pattern ButtonColor = S.SButtonColor
--- | The font family of the text
-pattern FontFamily = S.SFontFamily
--- | The font weight of the text
-pattern FontSize = S.SFontSize
--- | The font style of the text
-pattern FontStyle = S.SFontStyle
--- | The font variant of the text
-pattern FontVariant = S.SFontVariant
--- | The text color of the text
-pattern FontWeight = S.SFontWeight
--- | The font size of the text
-pattern TextColor = S.STextColor
--- | The text decoration of the text
-pattern TextDecoration = S.STextDecoration
--- | Width of the description to the side of the control
-pattern DescriptionWidth = S.SDescriptionWidth
--- | Color of the progress bar
-pattern BarColor = S.SBarColor
--- | Color of the slider handle
-pattern HandleColor = S.SHandleColor
--- | The width of each button
-pattern ButtonWidth = S.SButtonWidth
--- | The target (widget,field) pair
-pattern Target = S.STarget
--- | The source (widget,field) pair
-pattern Source = S.SSource
--- | Parent message id of messages to capture
-pattern MsgID = S.SMsgID
--- | The output messages synced from the frontend
-pattern Outputs = S.SOutputs
--- | Reference to a Style widget with styling customizations
-pattern Style = S.SStyle
-
-- | Close a widget's comm
closeWidget :: IHaskellWidget w => w -> IO ()
closeWidget w = widgetSendClose w emptyObject
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/Controller.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/Controller.hs
index 81f20340..c8e71f42 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/Controller.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/Controller.hs
@@ -3,6 +3,11 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
+{-# LANGUAGE MonoLocalBinds #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -32,7 +37,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | 'Controller' represents an Controller widget from IPython.html.widgets.
-type Controller = IPythonWidget 'ControllerType
+type Controller = IPythonWidget ControllerType
-- | Create a new widget
mkController :: IO Controller
@@ -42,14 +47,14 @@ mkController = do
layout <- mkLayout
let domAttrs = defaultCoreWidget <+> defaultDOMWidget "ControllerView" "ControllerModel" layout
- ctrlAttrs = (Index =:+ 0)
- :& (Name =:! "")
- :& (Mapping =:! "")
- :& (Connected =:! False)
- :& (Timestamp =:! 0.0)
- :& (Buttons =:! [])
- :& (Axes =:! [])
- :& (ChangeHandler =:: pure ())
+ ctrlAttrs = (F @Index =:+ 0)
+ :& (F @Name =:! "")
+ :& (F @Mapping =:! "")
+ :& (F @Connected =:! False)
+ :& (F @Timestamp =:! 0.0)
+ :& (F @Buttons =:! [])
+ :& (F @Axes =:! [])
+ :& (F @ChangeHandler =:: pure ())
:& RNil
widgetState = WidgetState $ domAttrs <+> ctrlAttrs
@@ -68,12 +73,15 @@ instance IHaskellWidget Controller where
comm widget val _ =
case nestedObjectLookup val ["state"] of
Just (Object o) -> do
- parseAndSet Name "name"
- parseAndSet Mapping "mapping"
- parseAndSet Connected "connected"
- parseAndSet Timestamp "timestamp"
+ parseAndSet @Name "name"
+ parseAndSet @Mapping "mapping"
+ parseAndSet @Connected "connected"
+ parseAndSet @Timestamp "timestamp"
triggerChange widget
- where parseAndSet f s = case parse (.: s) o of
- Success x -> void $ setField' widget f x
+ where parseAndSet :: forall f. (RElemOf f (WidgetFields ControllerType),
+ IHaskellWidget Controller,
+ ToKey f, FromJSON (FieldType f)) => Key -> IO ()
+ parseAndSet s = case parse (.: s) o of
+ Success x -> void $ setField' @f widget x
_ -> pure ()
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerAxis.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerAxis.hs
index 080191c2..9d82525f 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerAxis.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerAxis.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -28,7 +29,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | 'ControllerAxis' represents an ControllerAxis widget from IPython.html.widgets.
-type ControllerAxis = IPythonWidget 'ControllerAxisType
+type ControllerAxis = IPythonWidget ControllerAxisType
-- | Create a new widget
mkControllerAxis :: IO ControllerAxis
@@ -38,8 +39,8 @@ mkControllerAxis = do
layout <- mkLayout
let domAttrs = defaultCoreWidget <+> defaultDOMWidget "ControllerAxisView" "ControllerAxisModel" layout
- axisAttrs = (FloatValue =:! 0.0)
- :& (ChangeHandler =:: pure ())
+ axisAttrs = (F @FloatValue =:! 0.0)
+ :& (F @ChangeHandler =:: pure ())
:& RNil
widgetState = WidgetState $ domAttrs <+> axisAttrs
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerButton.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerButton.hs
index f99241ce..8fc29a32 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerButton.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Controller/ControllerButton.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -28,7 +29,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | 'ControllerButton' represents an ControllerButton widget from IPython.html.widgets.
-type ControllerButton = IPythonWidget 'ControllerButtonType
+type ControllerButton = IPythonWidget ControllerButtonType
-- | Create a new widget
mkControllerButton :: IO ControllerButton
@@ -38,9 +39,9 @@ mkControllerButton = do
layout <- mkLayout
let domAttrs = defaultCoreWidget <+> defaultDOMWidget "ControllerButtonView" "ControllerButtonModel" layout
- btnAttrs = (FloatValue =:! 0.0)
- :& (Pressed =:! False)
- :& (ChangeHandler =:: pure ())
+ btnAttrs = (F @FloatValue =:! 0.0)
+ :& (F @Pressed =:! False)
+ :& (F @ChangeHandler =:: pure ())
:& RNil
widgetState = WidgetState $ domAttrs <+> btnAttrs
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/DatePicker.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/DatePicker.hs
index 1240f1bd..a9c03dca 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/DatePicker.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/DatePicker.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'DatePicker' represents a DatePicker from IPython.html.widgets.
-type DatePicker = IPythonWidget 'DatePickerType
+type DatePicker = IPythonWidget DatePickerType
-- | Create a new DatePicker
mkDatePicker :: IO DatePicker
@@ -40,9 +41,9 @@ mkDatePicker = do
dstyle <- mkDescriptionStyle
let ddw = defaultDescriptionWidget "DatePickerView" "DatePickerModel" layout $ StyleWidget dstyle
- date = (DateValue =:: defaultDate)
- :& (Disabled =:: False)
- :& (ChangeHandler =:: return ())
+ date = (F @DateValue =:: defaultDate)
+ :& (F @Disabled =:: False)
+ :& (F @ChangeHandler =:: return ())
:& RNil
datePickerState = WidgetState (ddw <+> date)
@@ -61,6 +62,6 @@ instance IHaskellWidget DatePicker where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just o -> case fromJSON o of
- Success date -> setField' widget DateValue date >> triggerChange widget
+ Success date -> setField' @DateValue widget date >> triggerChange widget
_ -> pure ()
- _ -> pure ()
\ No newline at end of file
+ _ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs
index 95e16b05..46f07f62 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'BoundedFloatText' represents an BoundedFloatText widget from IPython.html.widgets.
-type BoundedFloatText = IPythonWidget 'BoundedFloatTextType
+type BoundedFloatText = IPythonWidget BoundedFloatTextType
-- | Create a new widget
mkBoundedFloatText :: IO BoundedFloatText
@@ -42,9 +43,9 @@ mkBoundedFloatText = do
dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatTextView" "BoundedFloatTextModel" layout $ StyleWidget dstyle
- textAttrs = (Disabled =:: False)
- :& (ContinuousUpdate =:: False)
- :& (StepFloat =:: Nothing)
+ textAttrs = (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: False)
+ :& (F @StepFloat =:: Nothing)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> textAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget BoundedFloatText where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget FloatValue (Sci.toRealFloat value)
+ void $ setField' @FloatValue widget (Sci.toRealFloat value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatLogSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatLogSlider.hs
index 2050effd..d2ed658a 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatLogSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatLogSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'FloatLogSlider' represents an FloatLogSlider widget from IPython.html.widgets.
-type FloatLogSlider = IPythonWidget 'FloatLogSliderType
+type FloatLogSlider = IPythonWidget FloatLogSliderType
-- | Create a new widget
mkFloatLogSlider :: IO FloatLogSlider
@@ -42,13 +43,13 @@ mkFloatLogSlider = do
dstyle <- mkDescriptionStyle
let boundedLogFloatAttrs = defaultBoundedLogFloatWidget "FloatLogSliderView" "FloatLogSliderModel" layout $ StyleWidget dstyle
- sliderAttrs = (StepFloat =:: Just 0.1)
- :& (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ReadOutFormat =:: ".3g")
- :& (ContinuousUpdate =:: True)
- :& (Disabled =:: False)
- :& (BaseFloat =:: 10.0)
+ sliderAttrs = (F @StepFloat =:: Just 0.1)
+ :& (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ReadOutFormat =:: ".3g")
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @Disabled =:: False)
+ :& (F @BaseFloat =:: 10.0)
:& RNil
widgetState = WidgetState $ boundedLogFloatAttrs <+> sliderAttrs
@@ -67,6 +68,6 @@ instance IHaskellWidget FloatLogSlider where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget FloatValue (Sci.toRealFloat value)
+ void $ setField' @FloatValue widget (Sci.toRealFloat value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs
index bd121e53..7fcb1b26 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.ProgressStyle
-- | 'FloatProgress' represents an FloatProgress widget from IPython.html.widgets.
-type FloatProgress = IPythonWidget 'FloatProgressType
+type FloatProgress = IPythonWidget FloatProgressType
-- | Create a new widget
mkFloatProgress :: IO FloatProgress
@@ -40,8 +41,8 @@ mkFloatProgress = do
pstyle <- mkProgressStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" "FloatProgressModel" layout $ StyleWidget pstyle
- progressAttrs = (Orientation =:: HorizontalOrientation)
- :& (BarStyle =:: DefaultBar)
+ progressAttrs = (F @Orientation =:: HorizontalOrientation)
+ :& (F @BarStyle =:: DefaultBar)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> progressAttrs
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs
index 998265b3..556c42ab 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'FloatSlider' represents an FloatSlider widget from IPython.html.widgets.
-type FloatSlider = IPythonWidget 'FloatSliderType
+type FloatSlider = IPythonWidget FloatSliderType
-- | Create a new widget
mkFloatSlider :: IO FloatSlider
@@ -42,12 +43,12 @@ mkFloatSlider = do
dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel" layout $ StyleWidget dstyle
- sliderAttrs = (StepFloat =:: Just 0.1)
- :& (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ReadOutFormat =:: ".2f")
- :& (ContinuousUpdate =:: True)
- :& (Disabled =:: False)
+ sliderAttrs = (F @StepFloat =:: Just 0.1)
+ :& (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ReadOutFormat =:: ".2f")
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> sliderAttrs
@@ -66,6 +67,6 @@ instance IHaskellWidget FloatSlider where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget FloatValue (Sci.toRealFloat value)
+ void $ setField' @FloatValue widget (Sci.toRealFloat value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs
index f8d374e8..efad57e7 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -32,7 +33,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'FloatRangeSlider' represents an FloatRangeSlider widget from IPython.html.widgets.
-type FloatRangeSlider = IPythonWidget 'FloatRangeSliderType
+type FloatRangeSlider = IPythonWidget FloatRangeSliderType
-- | Create a new widget
mkFloatRangeSlider :: IO FloatRangeSlider
@@ -43,12 +44,12 @@ mkFloatRangeSlider = do
dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatRangeSliderView" "FloatRangeSliderModel" layout $ StyleWidget dstyle
- sliderAttrs = (StepFloat =:: Just 0.1)
- :& (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ReadOutFormat =:: ".2f")
- :& (ContinuousUpdate =:: True)
- :& (Disabled =:: False)
+ sliderAttrs = (F @StepFloat =:: Just 0.1)
+ :& (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ReadOutFormat =:: ".2f")
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> sliderAttrs
@@ -69,7 +70,7 @@ instance IHaskellWidget FloatRangeSlider where
Just (Array values) ->
case map (\(Number x) -> Sci.toRealFloat x) $ V.toList values of
[x, y] -> do
- void $ setField' widget FloatPairValue (x, y)
+ void $ setField' @FloatPairValue widget (x, y)
triggerChange widget
_ -> pure ()
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs
index c140eb3e..09e42444 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Float/FloatText.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'FloatText' represents an FloatText widget from IPython.html.widgets.
-type FloatText = IPythonWidget 'FloatTextType
+type FloatText = IPythonWidget FloatTextType
-- | Create a new widget
mkFloatText :: IO FloatText
@@ -42,9 +43,9 @@ mkFloatText = do
dstyle <- mkDescriptionStyle
let floatAttrs = defaultFloatWidget "FloatTextView" "FloatTextModel" layout $ StyleWidget dstyle
- textAttrs = (Disabled =:: False)
- :& (ContinuousUpdate =:: False)
- :& (StepFloat =:: Nothing)
+ textAttrs = (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: False)
+ :& (F @StepFloat =:: Nothing)
:& RNil
widgetState = WidgetState $ floatAttrs <+> textAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget FloatText where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget FloatValue (Sci.toRealFloat value)
+ void $ setField' @FloatValue widget (Sci.toRealFloat value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs
index e73f6244..7e778c07 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'BoundedIntText' represents an BoundedIntText widget from IPython.html.widgets.
-type BoundedIntText = IPythonWidget 'BoundedIntTextType
+type BoundedIntText = IPythonWidget BoundedIntTextType
-- | Create a new widget
mkBoundedIntText :: IO BoundedIntText
@@ -42,9 +43,9 @@ mkBoundedIntText = do
dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "IntTextView" "BoundedIntTextModel" layout $ StyleWidget dstyle
- textAttrs = (Disabled =:: False)
- :& (ContinuousUpdate =:: False)
- :& (StepInt =:: Just 1)
+ textAttrs = (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: False)
+ :& (F @StepInt =:: Just 1)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> textAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget BoundedIntText where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget IntValue (Sci.coefficient value)
+ void $ setField' @IntValue widget (Sci.coefficient value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs
index 7a4e113d..fbf84382 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'IntProgress' represents an IntProgress widget from IPython.html.widgets.
-type IntProgress = IPythonWidget 'IntProgressType
+type IntProgress = IPythonWidget IntProgressType
-- | Create a new widget
mkIntProgress :: IO IntProgress
@@ -40,8 +41,8 @@ mkIntProgress = do
dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" "IntProgressModel" layout $ StyleWidget dstyle
- progressAttrs = (Orientation =:: HorizontalOrientation)
- :& (BarStyle =:: DefaultBar)
+ progressAttrs = (F @Orientation =:: HorizontalOrientation)
+ :& (F @BarStyle =:: DefaultBar)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> progressAttrs
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
index 5b50d371..f62f1db3 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'IntSlider' represents an IntSlider widget from IPython.html.widgets.
-type IntSlider = IPythonWidget 'IntSliderType
+type IntSlider = IPythonWidget IntSliderType
-- | Create a new widget
mkIntSlider :: IO IntSlider
@@ -42,12 +43,12 @@ mkIntSlider = do
dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel" layout $ StyleWidget dstyle
- sliderAttrs = (StepInt =:: Just 1)
- :& (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ReadOutFormat =:: "d")
- :& (ContinuousUpdate =:: True)
- :& (Disabled =:: False)
+ sliderAttrs = (F @StepInt =:: Just 1)
+ :& (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ReadOutFormat =:: "d")
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> sliderAttrs
@@ -66,6 +67,6 @@ instance IHaskellWidget IntSlider where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget IntValue (Sci.coefficient value)
+ void $ setField' @IntValue widget (Sci.coefficient value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs
index f57e6d6d..cc99239e 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'Play' represents an Play widget from IPython.html.widgets.
-type Play = IPythonWidget 'PlayType
+type Play = IPythonWidget PlayType
-- | Create a new widget
mkPlay :: IO Play
@@ -42,12 +43,12 @@ mkPlay = do
dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "PlayView" "PlayModel" layout $ StyleWidget dstyle
- playAttrs = (Playing =:: True)
- :& (Repeat =:: True)
- :& (Interval =:: 100)
- :& (StepInt =:: Just 1)
- :& (Disabled =:: False)
- :& (ShowRepeat =:: True)
+ playAttrs = (F @Playing =:: True)
+ :& (F @Repeat =:: True)
+ :& (F @Interval =:: 100)
+ :& (F @StepInt =:: Just 1)
+ :& (F @Disabled =:: False)
+ :& (F @ShowRepeat =:: True)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> playAttrs
@@ -66,6 +67,6 @@ instance IHaskellWidget Play where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget IntValue (Sci.coefficient value)
+ void $ setField' @IntValue widget (Sci.coefficient value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs
index 43b1da38..5d77e572 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -32,7 +33,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'IntRangeSlider' represents an IntRangeSlider widget from IPython.html.widgets.
-type IntRangeSlider = IPythonWidget 'IntRangeSliderType
+type IntRangeSlider = IPythonWidget IntRangeSliderType
-- | Create a new widget
mkIntRangeSlider :: IO IntRangeSlider
@@ -43,12 +44,12 @@ mkIntRangeSlider = do
dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntRangeSliderView" "IntRangeSliderModel" layout $ StyleWidget dstyle
- sliderAttrs = (StepInt =:: Just 1)
- :& (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ReadOutFormat =:: "d")
- :& (ContinuousUpdate =:: True)
- :& (Disabled =:: False)
+ sliderAttrs = (F @StepInt =:: Just 1)
+ :& (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ReadOutFormat =:: "d")
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> sliderAttrs
@@ -69,7 +70,7 @@ instance IHaskellWidget IntRangeSlider where
Just (Array values) ->
case map (\(Number x) -> Sci.coefficient x) $ V.toList values of
[x, y] -> do
- void $ setField' widget IntPairValue (x, y)
+ void $ setField' @IntPairValue widget (x, y)
triggerChange widget
_ -> pure ()
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs
index 2e1421db..5a3c8e30 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/IntText.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | 'IntText' represents an IntText widget from IPython.html.widgets.
-type IntText = IPythonWidget 'IntTextType
+type IntText = IPythonWidget IntTextType
-- | Create a new widget
mkIntText :: IO IntText
@@ -42,9 +43,9 @@ mkIntText = do
dstyle <- mkDescriptionStyle
let intAttrs = defaultIntWidget "IntTextView" "IntTextModel" layout $ StyleWidget dstyle
- textAttrs = (Disabled =:: False)
- :& (ContinuousUpdate =:: False)
- :& (StepInt =:: Just 1)
+ textAttrs = (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: False)
+ :& (F @StepInt =:: Just 1)
:& RNil
widgetState = WidgetState $ intAttrs <+> textAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget IntText where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do
- void $ setField' widget IntValue (Sci.coefficient value)
+ void $ setField' @IntValue widget (Sci.coefficient value)
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Interactive.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Interactive.hs
index e7501ea1..525fa9c8 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Interactive.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Interactive.hs
@@ -8,6 +8,9 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE PolyKinds #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeApplications #-}
module IHaskell.Display.Widgets.Interactive
( interactive
@@ -34,7 +37,7 @@ import IHaskell.Display
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-import qualified IHaskell.Display.Widgets.Singletons as S (SField, Field(..))
+import qualified IHaskell.Display.Widgets.Singletons as S
import IHaskell.Display.Widgets.Box.Box
import IHaskell.Display.Widgets.Bool.CheckBox
@@ -170,74 +173,73 @@ liftToWidgets func rc initvals = do
-- Set children for the Box
let children = mkChildren widgets
- setField bx Children $ children ++ [ChildWidget out]
+ setField @Children bx $ children ++ [ChildWidget out]
return bx
data WrappedWidget w h f a where
WrappedWidget ::
- (FieldType h ~ IO (), FieldType f ~ a, h ∈ WidgetFields w,
- f ∈ WidgetFields w, ToPairs (Attr h),
+ forall h f w a. (FieldType h ~ IO (), FieldType f ~ a, h ∈ WidgetFields w,
+ f ∈ WidgetFields w, ToPairs (Attr h), ToKey h,
IHaskellWidget (IPythonWidget w), ToPairs (Attr f)) =>
- IO (IPythonWidget w) ->
- S.SField h -> S.SField f -> WrappedWidget w h f a
+ IO (IPythonWidget w) -> WrappedWidget w h f a
construct :: WrappedWidget w h f a -> IO (IPythonWidget w)
-construct (WrappedWidget cs _ _) = cs
+construct (WrappedWidget cs) = cs
-getValue :: WrappedWidget w h f a -> IPythonWidget w -> IO a
-getValue (WrappedWidget _ _ field) widget = getField widget field
+getValue :: forall w h f a. WrappedWidget w h f a -> IPythonWidget w -> IO a
+getValue (WrappedWidget _) widget = getField @f widget
-setEvent :: WrappedWidget w h f a -> IPythonWidget w -> IO () -> IO ()
-setEvent (WrappedWidget _ h _) widget = setField widget h
+setEvent :: forall w h f a. WrappedWidget w h f a -> IPythonWidget w -> IO () -> IO ()
+setEvent (WrappedWidget _) widget = setField @h widget
class RecAll Attr (WidgetFields (SuitableWidget a)) ToPairs => FromWidget a where
- type SuitableWidget a :: WidgetType
- type SuitableHandler a :: S.Field
- type SuitableField a :: S.Field
+ type SuitableWidget a
+ type SuitableHandler a
+ type SuitableField a
data Argument a
initializer :: IPythonWidget (SuitableWidget a) -> Argument a -> IO ()
wrapped :: WrappedWidget (SuitableWidget a) (SuitableHandler a) (SuitableField a) a
instance FromWidget Bool where
- type SuitableWidget Bool = 'CheckBoxType
- type SuitableHandler Bool = 'S.ChangeHandler
- type SuitableField Bool = 'S.BoolValue
+ type SuitableWidget Bool = CheckBoxType
+ type SuitableHandler Bool = S.ChangeHandler
+ type SuitableField Bool = S.BoolValue
data Argument Bool = BoolVal Bool
- initializer w (BoolVal b) = setField w BoolValue b
- wrapped = WrappedWidget mkCheckBox ChangeHandler BoolValue
+ initializer w (BoolVal b) = setField @BoolValue w b
+ wrapped = WrappedWidget @ChangeHandler @BoolValue mkCheckBox
instance FromWidget Text where
- type SuitableWidget Text = 'TextType
- type SuitableHandler Text = 'S.SubmitHandler
- type SuitableField Text = 'S.StringValue
+ type SuitableWidget Text = TextType
+ type SuitableHandler Text = S.SubmitHandler
+ type SuitableField Text = S.StringValue
data Argument Text = TextVal Text
- initializer w (TextVal txt) = setField w StringValue txt
- wrapped = WrappedWidget mkText SubmitHandler StringValue
+ initializer w (TextVal txt) = setField @StringValue w txt
+ wrapped = WrappedWidget @SubmitHandler @StringValue mkText
instance FromWidget Integer where
- type SuitableWidget Integer = 'IntSliderType
- type SuitableHandler Integer = 'S.ChangeHandler
- type SuitableField Integer = 'S.IntValue
+ type SuitableWidget Integer = IntSliderType
+ type SuitableHandler Integer = S.ChangeHandler
+ type SuitableField Integer = S.IntValue
data Argument Integer = IntVal Integer
| IntRange (Integer, Integer, Integer)
- wrapped = WrappedWidget mkIntSlider ChangeHandler IntValue
- initializer w (IntVal int) = setField w IntValue int
+ wrapped = WrappedWidget @ChangeHandler @IntValue mkIntSlider
+ initializer w (IntVal int) = setField @IntValue w int
initializer w (IntRange (v, l, u)) = do
- setField w IntValue v
- setField w MinInt l
- setField w MaxInt u
+ setField @IntValue w v
+ setField @MinInt w l
+ setField @MaxInt w u
instance FromWidget Double where
- type SuitableWidget Double = 'FloatSliderType
- type SuitableHandler Double = 'S.ChangeHandler
- type SuitableField Double = 'S.FloatValue
+ type SuitableWidget Double = FloatSliderType
+ type SuitableHandler Double = S.ChangeHandler
+ type SuitableField Double = S.FloatValue
data Argument Double = FloatVal Double
| FloatRange (Double, Double, Double)
- wrapped = WrappedWidget mkFloatSlider ChangeHandler FloatValue
- initializer w (FloatVal d) = setField w FloatValue d
+ wrapped = WrappedWidget @ChangeHandler @FloatValue mkFloatSlider
+ initializer w (FloatVal d) = setField @FloatValue w d
initializer w (FloatRange (v, l, u)) = do
- setField w FloatValue v
- setField w MinFloat l
- setField w MaxFloat u
+ setField @FloatValue w v
+ setField @MinFloat w l
+ setField @MaxFloat w u
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs
index cc55cb57..9d4b4293 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Common.hs
@@ -15,45 +15,45 @@ module IHaskell.Display.Widgets.Layout.Common where
import qualified IHaskell.Display.Widgets.Singletons as S
-pattern AlignContent = S.SLAlignContent
-pattern AlignItems = S.SLAlignItems
-pattern AlignSelf = S.SLAlignSelf
-pattern BorderBottom = S.SLBorderBottom
-pattern BorderLeft = S.SLBorderLeft
-pattern BorderRight = S.SLBorderRight
-pattern BorderTop = S.SLBorderTop
-pattern Bottom = S.SLBottom
-pattern Display = S.SLDisplay
-pattern Flex = S.SLFlex
-pattern FlexFlow = S.SLFlexFlow
-pattern GridArea = S.SLGridArea
-pattern GridAutoColumns = S.SLGridAutoColumns
-pattern GridAutoFlow = S.SLGridAutoFlow
-pattern GridAutoRows = S.SLGridAutoRows
-pattern GridColumn = S.SLGridColumn
-pattern GridGap = S.SLGridGap
-pattern GridRow = S.SLGridRow
-pattern GridTemplateAreas = S.SLGridTemplateAreas
-pattern GridTemplateColumns = S.SLGridTemplateColumns
-pattern GridTemplateRows = S.SLGridTemplateRows
-pattern Height = S.SLHeight
-pattern JustifyContent = S.SLJustifyContent
-pattern JustifyItems = S.SLJustifyItems
-pattern Left = S.SLLeft
-pattern Margin = S.SLMargin
-pattern MaxHeight = S.SLMaxHeight
-pattern MaxWidth = S.SLMaxWidth
-pattern MinHeight = S.SLMinHeight
-pattern MinWidth = S.SLMinWidth
-pattern ObjectFit = S.SLObjectFit
-pattern ObjectPosition = S.SLObjectPosition
-pattern Order = S.SLOrder
-pattern Overflow = S.SLOverflow
-pattern Padding = S.SLPadding
-pattern Right = S.SLRight
-pattern Top = S.SLTop
-pattern Visibility = S.SLVisibility
-pattern Width = S.SLWidth
+type AlignContent = S.LAlignContent
+type AlignItems = S.LAlignItems
+type AlignSelf = S.LAlignSelf
+type BorderBottom = S.LBorderBottom
+type BorderLeft = S.LBorderLeft
+type BorderRight = S.LBorderRight
+type BorderTop = S.LBorderTop
+type Bottom = S.LBottom
+type Display = S.LDisplay
+type Flex = S.LFlex
+type FlexFlow = S.LFlexFlow
+type GridArea = S.LGridArea
+type GridAutoColumns = S.LGridAutoColumns
+type GridAutoFlow = S.LGridAutoFlow
+type GridAutoRows = S.LGridAutoRows
+type GridColumn = S.LGridColumn
+type GridGap = S.LGridGap
+type GridRow = S.LGridRow
+type GridTemplateAreas = S.LGridTemplateAreas
+type GridTemplateColumns = S.LGridTemplateColumns
+type GridTemplateRows = S.LGridTemplateRows
+type Height = S.LHeight
+type JustifyContent = S.LJustifyContent
+type JustifyItems = S.LJustifyItems
+type Left = S.LLeft
+type Margin = S.LMargin
+type MaxHeight = S.LMaxHeight
+type MaxWidth = S.LMaxWidth
+type MinHeight = S.LMinHeight
+type MinWidth = S.LMinWidth
+type ObjectFit = S.LObjectFit
+type ObjectPosition = S.LObjectPosition
+type Order = S.LOrder
+type Overflow = S.LOverflow
+type Padding = S.LPadding
+type Right = S.LRight
+type Top = S.LTop
+type Visibility = S.LVisibility
+type Width = S.LWidth
-- TODO: This should be implemented with static type checking, so it's
-- easier to verify at compile-time. "The Haskell Way".
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/LayoutWidget.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/LayoutWidget.hs
index 231b2bc7..97189dc7 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/LayoutWidget.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/LayoutWidget.hs
@@ -26,7 +26,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.Types
-- | A 'Layout' represents a Layout from IPython.html.widgets.
-type Layout = IPythonWidget 'LayoutType
+type Layout = IPythonWidget LayoutType
-- | Create a new Layout
mkLayout :: IO Layout
@@ -47,4 +47,4 @@ mkLayout = do
return layout
instance IHaskellWidget Layout where
- getCommUUID = uuid
\ No newline at end of file
+ getCommUUID = uuid
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs
index 0bc4bf11..d92de815 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Layout/Types.hs
@@ -16,6 +16,7 @@
{-# LANGUAGE AutoDeriveTypeable #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TypeApplications #-}
module IHaskell.Display.Widgets.Layout.Types where
@@ -33,143 +34,143 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.Common
-type LayoutClass = [ 'S.ModelModule
- , 'S.ModelModuleVersion
- , 'S.ModelName
- , 'S.ViewModule
- , 'S.ViewModuleVersion
- , 'S.ViewName
- , 'S.LAlignContent
- , 'S.LAlignItems
- , 'S.LAlignSelf
- , 'S.LBorderBottom
- , 'S.LBorderLeft
- , 'S.LBorderRight
- , 'S.LBorderTop
- , 'S.LBottom
- , 'S.LDisplay
- , 'S.LFlex
- , 'S.LFlexFlow
- , 'S.LGridArea
- , 'S.LGridAutoColumns
- , 'S.LGridAutoFlow
- , 'S.LGridAutoRows
- , 'S.LGridColumn
- , 'S.LGridGap
- , 'S.LGridRow
- , 'S.LGridTemplateAreas
- , 'S.LGridTemplateColumns
- , 'S.LGridTemplateRows
- , 'S.LHeight
- , 'S.LJustifyContent
- , 'S.LJustifyItems
- , 'S.LLeft
- , 'S.LMargin
- , 'S.LMaxHeight
- , 'S.LMaxWidth
- , 'S.LMinHeight
- , 'S.LMinWidth
- , 'S.LObjectFit
- , 'S.LObjectPosition
- , 'S.LOrder
- , 'S.LOverflow
- , 'S.LPadding
- , 'S.LRight
- , 'S.LTop
- , 'S.LVisibility
- , 'S.LWidth
+type LayoutClass = [ S.ModelModule
+ , S.ModelModuleVersion
+ , S.ModelName
+ , S.ViewModule
+ , S.ViewModuleVersion
+ , S.ViewName
+ , S.LAlignContent
+ , S.LAlignItems
+ , S.LAlignSelf
+ , S.LBorderBottom
+ , S.LBorderLeft
+ , S.LBorderRight
+ , S.LBorderTop
+ , S.LBottom
+ , S.LDisplay
+ , S.LFlex
+ , S.LFlexFlow
+ , S.LGridArea
+ , S.LGridAutoColumns
+ , S.LGridAutoFlow
+ , S.LGridAutoRows
+ , S.LGridColumn
+ , S.LGridGap
+ , S.LGridRow
+ , S.LGridTemplateAreas
+ , S.LGridTemplateColumns
+ , S.LGridTemplateRows
+ , S.LHeight
+ , S.LJustifyContent
+ , S.LJustifyItems
+ , S.LLeft
+ , S.LMargin
+ , S.LMaxHeight
+ , S.LMaxWidth
+ , S.LMinHeight
+ , S.LMinWidth
+ , S.LObjectFit
+ , S.LObjectPosition
+ , S.LOrder
+ , S.LOverflow
+ , S.LPadding
+ , S.LRight
+ , S.LTop
+ , S.LVisibility
+ , S.LWidth
]
-type instance FieldType 'S.LAlignContent = Maybe String
-type instance FieldType 'S.LAlignItems = Maybe String
-type instance FieldType 'S.LAlignSelf = Maybe String
-type instance FieldType 'S.LBorderBottom = Maybe String
-type instance FieldType 'S.LBorderLeft = Maybe String
-type instance FieldType 'S.LBorderRight = Maybe String
-type instance FieldType 'S.LBorderTop = Maybe String
-type instance FieldType 'S.LBottom = Maybe String
-type instance FieldType 'S.LDisplay = Maybe String
-type instance FieldType 'S.LFlex = Maybe String
-type instance FieldType 'S.LFlexFlow = Maybe String
-type instance FieldType 'S.LGridArea = Maybe String
-type instance FieldType 'S.LGridAutoColumns = Maybe String
-type instance FieldType 'S.LGridAutoFlow = Maybe String
-type instance FieldType 'S.LGridAutoRows = Maybe String
-type instance FieldType 'S.LGridColumn = Maybe String
-type instance FieldType 'S.LGridGap = Maybe String
-type instance FieldType 'S.LGridRow = Maybe String
-type instance FieldType 'S.LGridTemplateAreas = Maybe String
-type instance FieldType 'S.LGridTemplateColumns = Maybe String
-type instance FieldType 'S.LGridTemplateRows = Maybe String
-type instance FieldType 'S.LHeight = Maybe String
-type instance FieldType 'S.LJustifyContent = Maybe String
-type instance FieldType 'S.LJustifyItems = Maybe String
-type instance FieldType 'S.LLeft = Maybe String
-type instance FieldType 'S.LMargin = Maybe String
-type instance FieldType 'S.LMaxHeight = Maybe String
-type instance FieldType 'S.LMaxWidth = Maybe String
-type instance FieldType 'S.LMinHeight = Maybe String
-type instance FieldType 'S.LMinWidth = Maybe String
-type instance FieldType 'S.LObjectFit = Maybe String
-type instance FieldType 'S.LObjectPosition = Maybe String
-type instance FieldType 'S.LOrder = Maybe String
-type instance FieldType 'S.LOverflow = Maybe String
-type instance FieldType 'S.LPadding = Maybe String
-type instance FieldType 'S.LRight = Maybe String
-type instance FieldType 'S.LTop = Maybe String
-type instance FieldType 'S.LVisibility = Maybe String
-type instance FieldType 'S.LWidth = Maybe String
+type instance FieldType S.LAlignContent = Maybe String
+type instance FieldType S.LAlignItems = Maybe String
+type instance FieldType S.LAlignSelf = Maybe String
+type instance FieldType S.LBorderBottom = Maybe String
+type instance FieldType S.LBorderLeft = Maybe String
+type instance FieldType S.LBorderRight = Maybe String
+type instance FieldType S.LBorderTop = Maybe String
+type instance FieldType S.LBottom = Maybe String
+type instance FieldType S.LDisplay = Maybe String
+type instance FieldType S.LFlex = Maybe String
+type instance FieldType S.LFlexFlow = Maybe String
+type instance FieldType S.LGridArea = Maybe String
+type instance FieldType S.LGridAutoColumns = Maybe String
+type instance FieldType S.LGridAutoFlow = Maybe String
+type instance FieldType S.LGridAutoRows = Maybe String
+type instance FieldType S.LGridColumn = Maybe String
+type instance FieldType S.LGridGap = Maybe String
+type instance FieldType S.LGridRow = Maybe String
+type instance FieldType S.LGridTemplateAreas = Maybe String
+type instance FieldType S.LGridTemplateColumns = Maybe String
+type instance FieldType S.LGridTemplateRows = Maybe String
+type instance FieldType S.LHeight = Maybe String
+type instance FieldType S.LJustifyContent = Maybe String
+type instance FieldType S.LJustifyItems = Maybe String
+type instance FieldType S.LLeft = Maybe String
+type instance FieldType S.LMargin = Maybe String
+type instance FieldType S.LMaxHeight = Maybe String
+type instance FieldType S.LMaxWidth = Maybe String
+type instance FieldType S.LMinHeight = Maybe String
+type instance FieldType S.LMinWidth = Maybe String
+type instance FieldType S.LObjectFit = Maybe String
+type instance FieldType S.LObjectPosition = Maybe String
+type instance FieldType S.LOrder = Maybe String
+type instance FieldType S.LOverflow = Maybe String
+type instance FieldType S.LPadding = Maybe String
+type instance FieldType S.LRight = Maybe String
+type instance FieldType S.LTop = Maybe String
+type instance FieldType S.LVisibility = Maybe String
+type instance FieldType S.LWidth = Maybe String
--- type family WidgetFields (w :: WidgetType) :: [Field] where
-type instance WidgetFields 'LayoutType = LayoutClass
+-- type family WidgetFields w :: [*] where
+type instance WidgetFields LayoutType = LayoutClass
-- | A record representing a widget of the Layour class from IPython
defaultLayoutWidget :: Rec Attr LayoutClass
-defaultLayoutWidget = (S.SModelModule =:! "@jupyter-widgets/base")
- :& (S.SModelModuleVersion =:! "2.0.0")
- :& (S.SModelName =:! "LayoutModel")
- :& (S.SViewModule =:! "@jupyter-widgets/base")
- :& (S.SViewModuleVersion =:! "2.0.0")
- :& (S.SViewName =:! "LayoutView")
- :& (AlignContent =:. (Nothing, venum alignContentProps))
- :& (AlignItems =:. (Nothing, venum alignItemProps))
- :& (AlignSelf =:. (Nothing, venum alignSelfProps))
- :& (BorderBottom =:: Nothing)
- :& (BorderLeft =:: Nothing)
- :& (BorderRight =:: Nothing)
- :& (BorderTop =:: Nothing)
- :& (Bottom =:: Nothing)
- :& (Display =:: Nothing)
- :& (Flex =:: Nothing)
- :& (FlexFlow =:: Nothing)
- :& (GridArea =:: Nothing)
- :& (GridAutoColumns =:: Nothing)
- :& (GridAutoFlow =:. (Nothing, venum gridAutoFlowProps))
- :& (GridAutoRows =:: Nothing)
- :& (GridColumn =:: Nothing)
- :& (GridGap =:: Nothing)
- :& (GridRow =:: Nothing)
- :& (GridTemplateAreas =:: Nothing)
- :& (GridTemplateColumns =:: Nothing)
- :& (GridTemplateRows =:: Nothing)
- :& (Height =:: Nothing)
- :& (JustifyContent =:: Nothing)
- :& (JustifyItems =:: Nothing)
- :& (Left =:: Nothing)
- :& (Margin =:: Nothing)
- :& (MaxHeight =:: Nothing)
- :& (MaxWidth =:: Nothing)
- :& (MinHeight =:: Nothing)
- :& (MinWidth =:: Nothing)
- :& (ObjectFit =:: Nothing)
- :& (ObjectPosition =:: Nothing)
- :& (Order =:: Nothing)
- :& (Overflow =:. (Nothing, venum overflowProps))
- :& (Padding =:: Nothing)
- :& (Right =:: Nothing)
- :& (Top =:: Nothing)
- :& (Visibility =:. (Nothing, venum visibilityProps))
- :& (Width =:: Nothing)
+defaultLayoutWidget = ( F @S.ModelModule =:! "@jupyter-widgets/base")
+ :& (F @S.ModelModuleVersion =:! "2.0.0")
+ :& (F @S.ModelName =:! "LayoutModel")
+ :& (F @S.ViewModule =:! "@jupyter-widgets/base")
+ :& (F @S.ViewModuleVersion =:! "2.0.0")
+ :& (F @S.ViewName =:! "LayoutView")
+ :& (F @AlignContent =:. (Nothing, venum alignContentProps))
+ :& (F @AlignItems =:. (Nothing, venum alignItemProps))
+ :& (F @AlignSelf =:. (Nothing, venum alignSelfProps))
+ :& (F @BorderBottom =:: Nothing)
+ :& (F @BorderLeft =:: Nothing)
+ :& (F @BorderRight =:: Nothing)
+ :& (F @BorderTop =:: Nothing)
+ :& (F @Bottom =:: Nothing)
+ :& (F @Display =:: Nothing)
+ :& (F @Flex =:: Nothing)
+ :& (F @FlexFlow =:: Nothing)
+ :& (F @GridArea =:: Nothing)
+ :& (F @GridAutoColumns =:: Nothing)
+ :& (F @GridAutoFlow =:. (Nothing, venum gridAutoFlowProps))
+ :& (F @GridAutoRows =:: Nothing)
+ :& (F @GridColumn =:: Nothing)
+ :& (F @GridGap =:: Nothing)
+ :& (F @GridRow =:: Nothing)
+ :& (F @GridTemplateAreas =:: Nothing)
+ :& (F @GridTemplateColumns =:: Nothing)
+ :& (F @GridTemplateRows =:: Nothing)
+ :& (F @Height =:: Nothing)
+ :& (F @JustifyContent =:: Nothing)
+ :& (F @JustifyItems =:: Nothing)
+ :& (F @Left =:: Nothing)
+ :& (F @Margin =:: Nothing)
+ :& (F @MaxHeight =:: Nothing)
+ :& (F @MaxWidth =:: Nothing)
+ :& (F @MinHeight =:: Nothing)
+ :& (F @MinWidth =:: Nothing)
+ :& (F @ObjectFit =:: Nothing)
+ :& (F @ObjectPosition =:: Nothing)
+ :& (F @Order =:: Nothing)
+ :& (F @Overflow =:. (Nothing, venum overflowProps))
+ :& (F @Padding =:: Nothing)
+ :& (F @Right =:: Nothing)
+ :& (F @Top =:: Nothing)
+ :& (F @Visibility =:. (Nothing, venum visibilityProps))
+ :& (F @Width =:: Nothing)
:& RNil
where venum :: [String] -> Maybe String -> IO (Maybe String)
venum _ Nothing = return Nothing
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/DirectionalLink.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/DirectionalLink.hs
index 17057edc..1d84dfff 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/DirectionalLink.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/DirectionalLink.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -28,7 +29,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | An 'DirectionalLink' represents a DirectionalLink widget from IPython.html.widgets.
-type DirectionalLink = IPythonWidget 'DirectionalLinkType
+type DirectionalLink = IPythonWidget DirectionalLinkType
-- | Create a new DirectionalLink widget
mkDirectionalLink :: IO DirectionalLink
@@ -52,8 +53,8 @@ mkDirectionalLink = do
jsdlink :: WidgetFieldPair -> WidgetFieldPair -> IO DirectionalLink
jsdlink wfp1 wfp2 = do
dlink <- mkDirectionalLink
- _ <- setField dlink Source wfp1
- _ <- setField dlink Target wfp2
+ _ <- setField @Source dlink wfp1
+ _ <- setField @Target dlink wfp2
return dlink
instance IHaskellWidget DirectionalLink where
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/Link.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/Link.hs
index ee8d802c..6e541103 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/Link.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Link/Link.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -28,7 +29,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | An 'Link' represents a Link widget from IPython.html.widgets.
-type Link = IPythonWidget 'LinkType
+type Link = IPythonWidget LinkType
-- | Create a new link widget
mkLink :: IO Link
@@ -52,8 +53,8 @@ mkLink = do
jslink :: WidgetFieldPair -> WidgetFieldPair -> IO Link
jslink wfp1 wfp2 = do
link <- mkLink
- _ <- setField link Source wfp1
- _ <- setField link Target wfp2
+ _ <- setField @Source link wfp1
+ _ <- setField @Target link wfp2
return link
instance IHaskellWidget Link where
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Audio.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Audio.hs
index af0cd661..1fc1a881 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Audio.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Audio.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -28,7 +29,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | An 'AudioWidget' represents a Audio widget from IPython.html.widgets.
-type AudioWidget = IPythonWidget 'AudioType
+type AudioWidget = IPythonWidget AudioType
-- | Create a new audio widget
mkAudio :: IO AudioWidget
@@ -38,10 +39,10 @@ mkAudio = do
layout <- mkLayout
let mediaAttrs = defaultMediaWidget "AudioView" "AudioModel" layout
- audioAttrs = (AudioFormat =:: MP3)
- :& (AutoPlay =:: True)
- :& (Loop =:: True)
- :& (Controls =:: True)
+ audioAttrs = (F @AudioFormat =:: MP3)
+ :& (F @AutoPlay =:: True)
+ :& (F @Loop =:: True)
+ :& (F @Controls =:: True)
:& RNil
widgetState = WidgetState (mediaAttrs <+> audioAttrs)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Image.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Image.hs
index 8c18cc2a..9c92e641 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Image.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Image.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -24,11 +25,11 @@ import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
-import IHaskell.Display.Widgets.Common
+import IHaskell.Display.Widgets.Common as C
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | An 'ImageWidget' represents a Image widget from IPython.html.widgets.
-type ImageWidget = IPythonWidget 'ImageType
+type ImageWidget = IPythonWidget ImageType
-- | Create a new image widget
mkImage :: IO ImageWidget
@@ -38,9 +39,9 @@ mkImage = do
layout <- mkLayout
let mediaAttrs = defaultMediaWidget "ImageView" "ImageModel" layout
- imageAttrs = (ImageFormat =:: PNG)
- :& (Width =:+ 0)
- :& (Height =:+ 0)
+ imageAttrs = (F @ImageFormat =:: PNG)
+ :& (F @C.Width =:+ 0)
+ :& (F @C.Height =:+ 0)
:& RNil
widgetState = WidgetState (mediaAttrs <+> imageAttrs)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Video.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Video.hs
index 0a8367b5..1b958e31 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Video.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Media/Video.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -24,11 +25,11 @@ import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
-import IHaskell.Display.Widgets.Common
+import IHaskell.Display.Widgets.Common as C
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | An 'VideoWidget' represents a video widget from IPython.html.widgets.
-type VideoWidget = IPythonWidget 'VideoType
+type VideoWidget = IPythonWidget VideoType
-- | Create a new video widget
mkVideo :: IO VideoWidget
@@ -38,12 +39,12 @@ mkVideo = do
layout <- mkLayout
let mediaAttrs = defaultMediaWidget "VideoView" "VideoModel" layout
- videoAttrs = (VideoFormat =:: MP4)
- :& (Width =:+ 0)
- :& (Height =:+ 0)
- :& (AutoPlay =:: True)
- :& (Loop =:: True)
- :& (Controls =:: True)
+ videoAttrs = (F @VideoFormat =:: MP4)
+ :& (F @C.Width =:+ 0)
+ :& (F @C.Height =:+ 0)
+ :& (F @AutoPlay =:: True)
+ :& (F @Loop =:: True)
+ :& (F @Controls =:: True)
:& RNil
widgetState = WidgetState (mediaAttrs <+> videoAttrs)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
index d4d8d08a..ad443165 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -37,7 +38,7 @@ import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
-- | An 'OutputWidget' represents a Output widget from IPython.html.widgets.
-type OutputWidget = IPythonWidget 'OutputType
+type OutputWidget = IPythonWidget OutputType
-- | Create a new output widget
mkOutput :: IO OutputWidget
@@ -47,12 +48,12 @@ mkOutput = do
layout <- mkLayout
let domAttrs = defaultDOMWidget "OutputView" "OutputModel" layout
- outAttrs = (ViewModule =:! "@jupyter-widgets/output")
- :& (ModelModule =:! "@jupyter-widgets/output")
- :& (ViewModuleVersion =:! "1.0.0")
- :& (ModelModuleVersion =:! "1.0.0")
- :& (MsgID =:: "")
- :& (Outputs =:: [])
+ outAttrs = (F @ViewModule =:! "@jupyter-widgets/output")
+ :& (F @ModelModule =:! "@jupyter-widgets/output")
+ :& (F @ViewModuleVersion =:! "1.0.0")
+ :& (F @ModelModuleVersion =:! "1.0.0")
+ :& (F @MsgID =:: "")
+ :& (F @Outputs =:: [])
:& RNil
widgetState = WidgetState $ domAttrs <+> outAttrs
@@ -69,7 +70,7 @@ mkOutput = do
-- | Appends the Text to the given Stream
appendStd :: StreamType -> OutputWidget -> Text -> IO ()
appendStd n out t = do
- getField out Outputs >>= setField out Outputs . updateOutputs
+ getField @Outputs out >>= setField @Outputs out . updateOutputs
where updateOutputs :: [OutputMsg] -> [OutputMsg]
updateOutputs = (++[OutputStream n t])
@@ -84,16 +85,16 @@ appendStderr = appendStd Stderr
-- | Clears the output widget
clearOutput' :: OutputWidget -> IO ()
clearOutput' w = do
- _ <- setField w Outputs []
- _ <- setField w MsgID ""
+ _ <- setField @Outputs w []
+ _ <- setField @MsgID w ""
return ()
-- | Appends anything displayable to an output widget
appendDisplay :: IHaskellDisplay a => OutputWidget -> a -> IO ()
appendDisplay o d = do
- outputs <- getField o Outputs
+ outputs <- getField @Outputs o
disp <- display d
- _ <- setField o Outputs $ outputs ++ [OutputData disp]
+ _ <- setField @Outputs o $ outputs ++ [OutputData disp]
return ()
-- | Clear the output widget immediately
@@ -108,7 +109,7 @@ clearOutput_ widget = widgetClearOutput True >> clearOutput' widget
replaceOutput :: IHaskellDisplay a => OutputWidget -> a -> IO ()
replaceOutput widget d = do
disp <- display d
- setField widget Outputs [OutputData disp]
+ setField @Outputs widget [OutputData disp]
instance IHaskellWidget OutputWidget where
getCommUUID = uuid
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs
index 164e1823..90ebeaf3 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Dropdown.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'Dropdown' represents a Dropdown widget from IPython.html.widgets.
-type Dropdown = IPythonWidget 'DropdownType
+type Dropdown = IPythonWidget DropdownType
-- | Create a new Dropdown widget
mkDropdown :: IO Dropdown
@@ -57,6 +58,6 @@ instance IHaskellWidget Dropdown where
comm widget val _ =
case nestedObjectLookup val ["state", "index"] of
Just (Number index) -> do
- void $ setField' widget OptionalIndex (Just $ Sci.coefficient index)
+ void $ setField' @OptionalIndex widget (Just $ Sci.coefficient index)
triggerSelection widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs
index 426da15f..e6a11e0b 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/RadioButtons.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'RadioButtons' represents a RadioButtons widget from IPython.html.widgets.
-type RadioButtons = IPythonWidget 'RadioButtonsType
+type RadioButtons = IPythonWidget RadioButtonsType
-- | Create a new RadioButtons widget
mkRadioButtons :: IO RadioButtons
@@ -57,6 +58,6 @@ instance IHaskellWidget RadioButtons where
comm widget val _ =
case nestedObjectLookup val ["state", "index"] of
Just (Number index) -> do
- void $ setField' widget OptionalIndex (Just $ Sci.coefficient index)
+ void $ setField' @OptionalIndex widget (Just $ Sci.coefficient index)
triggerSelection widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs
index bf813d9e..dfde62e4 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/Select.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'Select' represents a Select widget from IPython.html.widgets.
-type Select = IPythonWidget 'SelectType
+type Select = IPythonWidget SelectType
-- | Create a new Select widget
mkSelect :: IO Select
@@ -42,7 +43,7 @@ mkSelect = do
dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionWidget "SelectView" "SelectModel" layout $ StyleWidget dstyle
- selectAttrs = (Rows =:: Just 5)
+ selectAttrs = (F @Rows =:: Just 5)
:& RNil
widgetState = WidgetState $ selectionAttrs <+> selectAttrs
@@ -61,6 +62,6 @@ instance IHaskellWidget Select where
comm widget val _ =
case nestedObjectLookup val ["state", "index"] of
Just (Number index) -> do
- void $ setField' widget OptionalIndex (Just $ Sci.coefficient index)
+ void $ setField' @OptionalIndex widget (Just $ Sci.coefficient index)
triggerSelection widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs
index cee3a6ae..297d5833 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -32,7 +33,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'SelectMultiple' represents a SelectMultiple widget from IPython.html.widgets.
-type SelectMultiple = IPythonWidget 'SelectMultipleType
+type SelectMultiple = IPythonWidget SelectMultipleType
-- | Create a new SelectMultiple widget
mkSelectMultiple :: IO SelectMultiple
@@ -43,7 +44,7 @@ mkSelectMultiple = do
dstyle <- mkDescriptionStyle
let multipleSelectionAttrs = defaultMultipleSelectionWidget "SelectMultipleView" "SelectMultipleModel" layout $ StyleWidget dstyle
- selectMultipleAttrs = (Rows =:: Just 5)
+ selectMultipleAttrs = (F @Rows =:: Just 5)
:& RNil
widgetState = WidgetState $ multipleSelectionAttrs <+> selectMultipleAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget SelectMultiple where
case nestedObjectLookup val ["state", "index"] of
Just (Array indices) -> do
let indicesList = map (\(Number x) -> Sci.coefficient x) $ V.toList indices
- void $ setField' widget Indices indicesList
+ void $ setField' @Indices widget indicesList
triggerSelection widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionRangeSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionRangeSlider.hs
index 5f09438b..bd4db837 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionRangeSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionRangeSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -32,7 +33,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'SelectionRangeSlider' represents a SelectionSlider widget from IPyhon.widgets
-type SelectionRangeSlider = IPythonWidget 'SelectionRangeSliderType
+type SelectionRangeSlider = IPythonWidget SelectionRangeSliderType
-- | Create a new SelectionRangeSlider widget
mkSelectionRangeSlider :: IO SelectionRangeSlider
@@ -42,11 +43,11 @@ mkSelectionRangeSlider = do
dstyle <- mkDescriptionStyle
let selectionAttrs = defaultMultipleSelectionWidget "SelectionRangeSliderView" "SelectionRangeSliderModel" layout $ StyleWidget dstyle
- selectionRangeSliderAttrs = (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ContinuousUpdate =:: True)
+ selectionRangeSliderAttrs = (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ContinuousUpdate =:: True)
:& RNil
- widgetState = WidgetState $ rput (Indices =:. ([0,0], rangeSliderVerification)) $ selectionAttrs <+> selectionRangeSliderAttrs
+ widgetState = WidgetState $ rput (F @Indices =:. ([0,0], rangeSliderVerification)) $ selectionAttrs <+> selectionRangeSliderAttrs
stateIO <- newIORef widgetState
@@ -64,6 +65,6 @@ instance IHaskellWidget SelectionRangeSlider where
case nestedObjectLookup val ["state", "index"] of
Just (Array indices) -> do
let indicesList = map (\(Number x) -> Sci.coefficient x) $ V.toList indices
- void $ setField' widget Indices indicesList
+ void $ setField' @Indices widget indicesList
triggerSelection widget
- _ -> pure ()
\ No newline at end of file
+ _ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionSlider.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionSlider.hs
index 7a3d60d7..5c7a82b6 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionSlider.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/SelectionSlider.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'SelectionSlider' represents a SelectionSlider widget from IPyhon.widgets
-type SelectionSlider = IPythonWidget 'SelectionSliderType
+type SelectionSlider = IPythonWidget SelectionSliderType
-- | Create a new SelectionSLider widget
mkSelectionSlider :: IO SelectionSlider
@@ -41,9 +42,9 @@ mkSelectionSlider = do
dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionNonemptyWidget "SelectionSliderView" "SelectionSliderModel" layout $ StyleWidget dstyle
- selectionSliderAttrs = (Orientation =:: HorizontalOrientation)
- :& (ReadOut =:: True)
- :& (ContinuousUpdate =:: True)
+ selectionSliderAttrs = (F @Orientation =:: HorizontalOrientation)
+ :& (F @ReadOut =:: True)
+ :& (F @ContinuousUpdate =:: True)
:& RNil
widgetState = WidgetState $ selectionAttrs <+> selectionSliderAttrs
@@ -62,6 +63,6 @@ instance IHaskellWidget SelectionSlider where
comm widget val _ =
case nestedObjectLookup val ["state", "index"] of
Just (Number index) -> do
- void $ setField' widget Index (Sci.coefficient index)
+ void $ setField' @Index widget (Sci.coefficient index)
triggerSelection widget
- _ -> pure ()
\ No newline at end of file
+ _ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs
index aafc2f5f..1f5f2380 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -31,7 +32,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'ToggleButtons' represents a ToggleButtons widget from IPython.html.widgets.
-type ToggleButtons = IPythonWidget 'ToggleButtonsType
+type ToggleButtons = IPythonWidget ToggleButtonsType
-- | Create a new ToggleButtons widget
mkToggleButtons :: IO ToggleButtons
@@ -42,9 +43,9 @@ mkToggleButtons = do
dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" "ToggleButtonsModel" layout $ StyleWidget dstyle
- toggleButtonsAttrs = (Tooltips =:: [])
- :& (Icons =:: [])
- :& (ButtonStyle =:: DefaultButton)
+ toggleButtonsAttrs = (F @Tooltips =:: [])
+ :& (F @Icons =:: [])
+ :& (F @ButtonStyleField =:: DefaultButton)
:& RNil
widgetState = WidgetState $ selectionAttrs <+> toggleButtonsAttrs
@@ -63,6 +64,6 @@ instance IHaskellWidget ToggleButtons where
comm widget val _ =
case nestedObjectLookup val ["state", "index"] of
Just (Number index) -> do
- void $ setField' widget OptionalIndex (Just $ Sci.coefficient index)
+ void $ setField' @OptionalIndex widget (Just $ Sci.coefficient index)
triggerSelection widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
index b4562713..8ef3479f 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
@@ -12,6 +12,7 @@
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
#if __GLASGOW_HASKELL__ >= 810
{-# LANGUAGE StandaloneKindSignatures #-}
#endif
@@ -19,306 +20,703 @@
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module IHaskell.Display.Widgets.Singletons where
+import Data.Typeable (Typeable)
-#if MIN_VERSION_singletons(3,0,0)
-import Data.Singletons.Base.TH
-import Data.Eq.Singletons
-#elif MIN_VERSION_singletons(2,4,0)
-import Data.Singletons.Prelude.Eq
-import Data.Singletons.TH
-#else
-import Data.Singletons.Prelude.Eq
-import Data.Singletons.Prelude.Ord
-import Data.Singletons.TH
-#endif
+-- Separate types for each Field, no constructors needed
+data ViewModule
+data ViewModuleVersion
+data ViewName
+data ModelModule
+data ModelModuleVersion
+data ModelName
+data DisplayHandler
+data DOMClasses
+data Layout
+data Width
+data Height
+data Description
+data DescriptionAllowHtml
+data ClickHandler
+data SubmitHandler
+data Disabled
+data StringValue
+data Placeholder
+data Tooltip
+data Tabbable
+data Icon
+data ButtonStyleField
+data BSValue
+data ImageFormat
+data BoolValue
+data OptionsLabels
+data Index
+data OptionalIndex
+data SelectionHandler
+data Tooltips
+data Icons
+data Indices
+data IntValue
+data StepInt
+data MaxInt
+data MinInt
+data IntPairValue
+data LowerInt
+data UpperInt
+data FloatValue
+data StepFloat
+data MaxFloat
+data MinFloat
+data FloatPairValue
+data LowerFloat
+data UpperFloat
+data Orientation
+data BaseFloat
+data ReadOut
+data ReadOutFormat
+data BarStyle
+data ChangeHandler
+data Children
+data BoxStyle
+data Titles
+data SelectedIndex
+data ReadOutMsg
+data Indent
+data ContinuousUpdate
+data Rows
+data AudioFormat
+data VideoFormat
+data AutoPlay
+data Loop
+data Controls
+data Options
+data EnsureOption
+data Playing
+data Repeat
+data Interval
+data ShowRepeat
+data Concise
+data DateValue
+data Pressed
+data Name
+data Mapping
+data Connected
+data Timestamp
+data Buttons
+data Axes
+data ButtonColor
+data FontFamily
+data FontStyle
+data FontSize
+data FontVariant
+data FontWeight
+data TextColor
+data TextDecoration
+data DescriptionWidth
+data BarColor
+data HandleColor
+data ButtonWidth
+data Target
+data Source
+data MsgID
+data Outputs
+data Style
--- Widget properties
-singletons
- [d|
+-- Layout fields with an 'L' prefix
+data LAlignContent
+data LAlignItems
+data LAlignSelf
+data LBorderBottom
+data LBorderLeft
+data LBorderRight
+data LBorderTop
+data LBottom
+data LDisplay
+data LFlex
+data LFlexFlow
+data LGridArea
+data LGridAutoColumns
+data LGridAutoFlow
+data LGridAutoRows
+data LGridColumn
+data LGridGap
+data LGridRow
+data LGridTemplateAreas
+data LGridTemplateColumns
+data LGridTemplateRows
+data LHeight
+data LJustifyContent
+data LJustifyItems
+data LLeft
+data LMargin
+data LMaxHeight
+data LMaxWidth
+data LMinHeight
+data LMinWidth
+data LObjectFit
+data LObjectPosition
+data LOrder
+data LOverflow
+data LPadding
+data LRight
+data LTop
+data LVisibility
+data LWidth
- data Field = ViewModule
- | ViewModuleVersion
- | ViewName
- | ModelModule
- | ModelModuleVersion
- | ModelName
- | DisplayHandler
- | DOMClasses
- | Layout
- | Width
- | Height
- | Description
- | DescriptionAllowHtml
- | ClickHandler
- | SubmitHandler
- | Disabled
- | StringValue
- | Placeholder
- | Tooltip
- | Tabbable
- | Icon
- | ButtonStyle
- | BSValue
- | ImageFormat
- | BoolValue
- | OptionsLabels
- | Index
- | OptionalIndex
- | SelectionHandler
- | Tooltips
- | Icons
- | Indices
- | IntValue
- | StepInt
- | MaxInt
- | MinInt
- | IntPairValue
- | LowerInt
- | UpperInt
- | FloatValue
- | StepFloat
- | MaxFloat
- | MinFloat
- | FloatPairValue
- | LowerFloat
- | UpperFloat
- | Orientation
- | BaseFloat
- | ReadOut
- | ReadOutFormat
- | BarStyle
- | ChangeHandler
- | Children
- | BoxStyle
- | Titles
- | SelectedIndex
- | ReadOutMsg
- | Indent
- | ContinuousUpdate
- | Rows
- | AudioFormat
- | VideoFormat
- | AutoPlay
- | Loop
- | Controls
- | Options
- | EnsureOption
- | Playing
- | Repeat
- | Interval
- | ShowRepeat
- | Concise
- | DateValue
- | Pressed
- | Name
- | Mapping
- | Connected
- | Timestamp
- | Buttons
- | Axes
- | ButtonColor
- | FontFamily
- | FontStyle
- | FontSize
- | FontVariant
- | FontWeight
- | TextColor
- | TextDecoration
- | DescriptionWidth
- | BarColor
- | HandleColor
- | ButtonWidth
- | Target
- | Source
- | MsgID
- | Outputs
- | Style
- -- Now the ones for layout
- -- Every layout property comes with an L before the name to avoid conflict
- -- The patterns from Layout.Common remove that leading L
- | LAlignContent
- | LAlignItems
- | LAlignSelf
- | LBorderBottom
- | LBorderLeft
- | LBorderRight
- | LBorderTop
- | LBottom
- | LDisplay
- | LFlex
- | LFlexFlow
- | LGridArea
- | LGridAutoColumns
- | LGridAutoFlow
- | LGridAutoRows
- | LGridColumn
- | LGridGap
- | LGridRow
- | LGridTemplateAreas
- | LGridTemplateColumns
- | LGridTemplateRows
- | LHeight
- | LJustifyContent
- | LJustifyItems
- | LLeft
- | LMargin
- | LMaxHeight
- | LMaxWidth
- | LMinHeight
- | LMinWidth
- | LObjectFit
- | LObjectPosition
- | LOrder
- | LOverflow
- | LPadding
- | LRight
- | LTop
- | LVisibility
- | LWidth
- deriving (Eq, Ord, Show)
- |]
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE DataKinds #-}
--- Attributes that aren't synced with the frontend give "" on toKey
-promote
- [d|
- -- toKey :: Field -> String
- toKey ViewModule = "_view_module"
- toKey ViewModuleVersion = "_view_module_version"
- toKey ViewName = "_view_name"
- toKey ModelModule = "_model_module"
- toKey ModelModuleVersion = "_model_module_version"
- toKey ModelName = "_model_name"
- toKey DisplayHandler = "" -- Not sent to the frontend
- toKey DOMClasses = "_dom_classes"
- toKey Width = "width"
- toKey Height = "height"
- toKey Description = "description"
- toKey DescriptionAllowHtml = "description_allow_html"
- toKey ClickHandler = "" -- Not sent to the frontend
- toKey SubmitHandler = "" -- Not sent to the frontend
- toKey Disabled = "disabled"
- toKey StringValue = "value"
- toKey Placeholder = "placeholder"
- toKey Tooltip = "tooltip"
- toKey Tabbable = "tabbable"
- toKey Icon = "icon"
- toKey ButtonStyle = "button_style"
- toKey BSValue = "value"
- toKey ImageFormat = "format"
- toKey AudioFormat = "format"
- toKey VideoFormat = "format"
- toKey BoolValue = "value"
- toKey Index = "index"
- toKey OptionalIndex = "index"
- toKey OptionsLabels = "_options_labels"
- toKey SelectionHandler = "" -- Not sent to the frontend
- toKey Tooltips = "tooltips"
- toKey Icons = "icons"
- toKey Indices = "index"
- toKey IntValue = "value"
- toKey StepInt = "step"
- toKey MinInt = "min"
- toKey MaxInt = "max"
- toKey IntPairValue = "value"
- toKey LowerInt = "min"
- toKey UpperInt = "max"
- toKey FloatValue = "value"
- toKey StepFloat = "step"
- toKey MinFloat = "min"
- toKey MaxFloat = "max"
- toKey FloatPairValue = "value"
- toKey LowerFloat = "min"
- toKey UpperFloat = "max"
- toKey Orientation = "orientation"
- toKey BaseFloat = "base"
- toKey ReadOut = "readout"
- toKey ReadOutFormat = "readout_format"
- toKey BarStyle = "bar_style"
- toKey ChangeHandler = "" -- Not sent to the frontend
- toKey Children = "children"
- toKey BoxStyle = "box_style"
- toKey Titles = "titles"
- toKey SelectedIndex = "selected_index"
- toKey ReadOutMsg = "readout"
- toKey Indent = "indent"
- toKey ContinuousUpdate = "continuous_update"
- toKey Rows = "rows"
- toKey AutoPlay = "autoplay"
- toKey Loop = "loop"
- toKey Controls = "controls"
- toKey Options = "options"
- toKey EnsureOption = "ensure_option"
- toKey Playing = "playing"
- toKey Repeat = "repeat"
- toKey Interval = "interval"
- toKey ShowRepeat = "show_repeat"
- toKey Concise = "concise"
- toKey DateValue = "value"
- toKey Pressed = "pressed"
- toKey Name = "name"
- toKey Mapping = "mapping"
- toKey Connected = "connected"
- toKey Timestamp = "timestamp"
- toKey Buttons = "buttons"
- toKey Axes = "axes"
- toKey Layout = "layout"
- toKey ButtonColor = "button_color"
- toKey FontFamily = "font_family"
- toKey FontSize = "font_size"
- toKey FontStyle = "font_style"
- toKey FontVariant = "font_variant"
- toKey FontWeight = "font_weight"
- toKey TextColor = "text_color"
- toKey TextDecoration = "text_decoration"
- toKey DescriptionWidth = "description_width"
- toKey BarColor = "bar_color"
- toKey HandleColor = "handle_color"
- toKey ButtonWidth = "button_width"
- toKey Target = "target"
- toKey Source = "source"
- toKey MsgID = "msg_id"
- toKey Outputs = "outputs"
- toKey Style = "style"
- toKey LAlignContent = "align_content"
- toKey LAlignItems = "align_items"
- toKey LAlignSelf = "align_self"
- toKey LBorderBottom = "border_bottom"
- toKey LBorderLeft = "border_left"
- toKey LBorderRight = "border_right"
- toKey LBorderTop = "border_top"
- toKey LBottom = "bottom"
- toKey LDisplay = "display"
- toKey LFlex = "flex"
- toKey LFlexFlow = "flex_flow"
- toKey LGridArea = "grid_area"
- toKey LGridAutoColumns = "grid_auto_columns"
- toKey LGridAutoFlow = "grid_auto_flow"
- toKey LGridAutoRows = "grid_auto_rows"
- toKey LGridColumn = "grid_column"
- toKey LGridGap = "grid_gap"
- toKey LGridRow = "grid_row"
- toKey LGridTemplateAreas = "grid_template_areas"
- toKey LGridTemplateColumns = "grid_template_columns"
- toKey LGridTemplateRows = "grid_template_rows"
- toKey LHeight = "height"
- toKey LJustifyContent = "justify_content"
- toKey LJustifyItems = "justify_items"
- toKey LLeft = "left"
- toKey LMargin = "margin"
- toKey LMaxHeight = "max_height"
- toKey LMaxWidth = "max_width"
- toKey LMinHeight = "min_height"
- toKey LMinWidth = "min_width"
- toKey LObjectFit = "object_fit"
- toKey LObjectPosition = "object_position"
- toKey LOrder = "order"
- toKey LOverflow = "overflow"
- toKey LPadding = "padding"
- toKey LRight = "right"
- toKey LTop = "top"
- toKey LVisibility = "visibility"
- toKey LWidth = "width"
+-- Define a class with an associated type family HasKey
+class Typeable a => ToKey a where
+ toKey :: String
+ type HasKey a :: Bool
- -- hasKey :: Field -> Bool
- hasKey x = toKey x /= ""
- |]
+-- Implementing instances for each field
+
+instance ToKey ViewModule where
+ toKey = "_view_module"
+ type HasKey ViewModule = 'True
+
+instance ToKey ViewModuleVersion where
+ toKey = "_view_module_version"
+ type HasKey ViewModuleVersion = 'True
+
+instance ToKey ViewName where
+ toKey = "_view_name"
+ type HasKey ViewName = 'True
+
+instance ToKey ModelModule where
+ toKey = "_model_module"
+ type HasKey ModelModule = 'True
+
+instance ToKey ModelModuleVersion where
+ toKey = "_model_module_version"
+ type HasKey ModelModuleVersion = 'True
+
+instance ToKey ModelName where
+ toKey = "_model_name"
+ type HasKey ModelName = 'True
+
+instance ToKey DisplayHandler where
+ toKey = "" -- Not sent to the frontend
+ type HasKey DisplayHandler = 'False
+
+instance ToKey DOMClasses where
+ toKey = "_dom_classes"
+ type HasKey DOMClasses = 'True
+
+instance ToKey Width where
+ toKey = "width"
+ type HasKey Width = 'True
+
+instance ToKey Height where
+ toKey = "height"
+ type HasKey Height = 'True
+
+instance ToKey Description where
+ toKey = "description"
+ type HasKey Description = 'True
+
+instance ToKey DescriptionAllowHtml where
+ toKey = "description_allow_html"
+ type HasKey DescriptionAllowHtml = 'True
+
+instance ToKey ClickHandler where
+ toKey = "" -- Not sent to the frontend
+ type HasKey ClickHandler = 'False
+
+instance ToKey SubmitHandler where
+ toKey = "" -- Not sent to the frontend
+ type HasKey SubmitHandler = 'False
+
+instance ToKey Disabled where
+ toKey = "disabled"
+ type HasKey Disabled = 'True
+
+instance ToKey StringValue where
+ toKey = "value"
+ type HasKey StringValue = 'True
+
+instance ToKey Placeholder where
+ toKey = "placeholder"
+ type HasKey Placeholder = 'True
+
+instance ToKey Tooltip where
+ toKey = "tooltip"
+ type HasKey Tooltip = 'True
+
+instance ToKey Tabbable where
+ toKey = "tabbable"
+ type HasKey Tabbable = 'True
+
+instance ToKey Icon where
+ toKey = "icon"
+ type HasKey Icon = 'True
+
+instance ToKey ButtonStyleField where
+ toKey = "button_style"
+ type HasKey ButtonStyleField = 'True
+
+instance ToKey BSValue where
+ toKey = "value"
+ type HasKey BSValue = 'True
+
+instance ToKey ImageFormat where
+ toKey = "format"
+ type HasKey ImageFormat = 'True
+
+instance ToKey AudioFormat where
+ toKey = "format"
+ type HasKey AudioFormat = 'True
+
+instance ToKey VideoFormat where
+ toKey = "format"
+ type HasKey VideoFormat = 'True
+
+instance ToKey BoolValue where
+ toKey = "value"
+ type HasKey BoolValue = 'True
+
+instance ToKey Index where
+ toKey = "index"
+ type HasKey Index = 'True
+
+instance ToKey OptionalIndex where
+ toKey = "index"
+ type HasKey OptionalIndex = 'True
+
+instance ToKey OptionsLabels where
+ toKey = "_options_labels"
+ type HasKey OptionsLabels = 'True
+
+instance ToKey SelectionHandler where
+ toKey = "" -- Not sent to the frontend
+ type HasKey SelectionHandler = 'False
+
+instance ToKey Tooltips where
+ toKey = "tooltips"
+ type HasKey Tooltips = 'True
+
+instance ToKey Icons where
+ toKey = "icons"
+ type HasKey Icons = 'True
+
+instance ToKey Indices where
+ toKey = "index"
+ type HasKey Indices = 'True
+
+instance ToKey IntValue where
+ toKey = "value"
+ type HasKey IntValue = 'True
+
+instance ToKey StepInt where
+ toKey = "step"
+ type HasKey StepInt = 'True
+
+instance ToKey MinInt where
+ toKey = "min"
+ type HasKey MinInt = 'True
+
+instance ToKey MaxInt where
+ toKey = "max"
+ type HasKey MaxInt = 'True
+
+instance ToKey IntPairValue where
+ toKey = "value"
+ type HasKey IntPairValue = 'True
+
+instance ToKey LowerInt where
+ toKey = "min"
+ type HasKey LowerInt = 'True
+
+instance ToKey UpperInt where
+ toKey = "max"
+ type HasKey UpperInt = 'True
+
+instance ToKey FloatValue where
+ toKey = "value"
+ type HasKey FloatValue = 'True
+
+instance ToKey StepFloat where
+ toKey = "step"
+ type HasKey StepFloat = 'True
+
+instance ToKey MinFloat where
+ toKey = "min"
+ type HasKey MinFloat = 'True
+
+instance ToKey MaxFloat where
+ toKey = "max"
+ type HasKey MaxFloat = 'True
+
+instance ToKey FloatPairValue where
+ toKey = "value"
+ type HasKey FloatPairValue = 'True
+
+instance ToKey LowerFloat where
+ toKey = "min"
+ type HasKey LowerFloat = 'True
+
+instance ToKey UpperFloat where
+ toKey = "max"
+ type HasKey UpperFloat = 'True
+
+instance ToKey Orientation where
+ toKey = "orientation"
+ type HasKey Orientation = 'True
+
+instance ToKey BaseFloat where
+ toKey = "base"
+ type HasKey BaseFloat = 'True
+
+instance ToKey ReadOut where
+ toKey = "readout"
+ type HasKey ReadOut = 'True
+
+instance ToKey ReadOutFormat where
+ toKey = "readout_format"
+ type HasKey ReadOutFormat = 'True
+
+instance ToKey BarStyle where
+ toKey = "bar_style"
+ type HasKey BarStyle = 'True
+
+instance ToKey ChangeHandler where
+ toKey = "" -- Not sent to the frontend
+ type HasKey ChangeHandler = 'False
+
+instance ToKey Children where
+ toKey = "children"
+ type HasKey Children = 'True
+
+instance ToKey BoxStyle where
+ toKey = "box_style"
+ type HasKey BoxStyle = 'True
+
+instance ToKey Titles where
+ toKey = "titles"
+ type HasKey Titles = 'True
+
+instance ToKey SelectedIndex where
+ toKey = "selected_index"
+ type HasKey SelectedIndex = 'True
+
+instance ToKey ReadOutMsg where
+ toKey = "readout"
+ type HasKey ReadOutMsg = 'True
+
+instance ToKey Indent where
+ toKey = "indent"
+ type HasKey Indent = 'True
+
+instance ToKey ContinuousUpdate where
+ toKey = "continuous_update"
+ type HasKey ContinuousUpdate = 'True
+
+instance ToKey Rows where
+ toKey = "rows"
+ type HasKey Rows = 'True
+
+instance ToKey AutoPlay where
+ toKey = "autoplay"
+ type HasKey AutoPlay = 'True
+
+instance ToKey Loop where
+ toKey = "loop"
+ type HasKey Loop = 'True
+
+instance ToKey Controls where
+ toKey = "controls"
+ type HasKey Controls = 'True
+
+instance ToKey Options where
+ toKey = "options"
+ type HasKey Options = 'True
+
+instance ToKey EnsureOption where
+ toKey = "ensure_option"
+ type HasKey EnsureOption = 'True
+
+instance ToKey Playing where
+ toKey = "playing"
+ type HasKey Playing = 'True
+
+instance ToKey Repeat where
+ toKey = "repeat"
+ type HasKey Repeat = 'True
+
+instance ToKey Interval where
+ toKey = "interval"
+ type HasKey Interval = 'True
+
+instance ToKey ShowRepeat where
+ toKey = "show_repeat"
+ type HasKey ShowRepeat = 'True
+
+instance ToKey Concise where
+ toKey = "concise"
+ type HasKey Concise = 'True
+
+instance ToKey DateValue where
+ toKey = "value"
+ type HasKey DateValue = 'True
+
+instance ToKey Pressed where
+ toKey = "pressed"
+ type HasKey Pressed = 'True
+
+instance ToKey Name where
+ toKey = "name"
+ type HasKey Name = 'True
+
+instance ToKey Mapping where
+ toKey = "mapping"
+ type HasKey Mapping = 'True
+
+instance ToKey Connected where
+ toKey = "connected"
+ type HasKey Connected = 'True
+
+instance ToKey Timestamp where
+ toKey = "timestamp"
+ type HasKey Timestamp = 'True
+
+instance ToKey Buttons where
+ toKey = "buttons"
+ type HasKey Buttons = 'True
+
+instance ToKey Axes where
+ toKey = "axes"
+ type HasKey Axes = 'True
+
+instance ToKey Layout where
+ toKey = "layout"
+ type HasKey Layout = 'True
+
+instance ToKey ButtonColor where
+ toKey = "button_color"
+ type HasKey ButtonColor = 'True
+
+instance ToKey FontFamily where
+ toKey = "font_family"
+ type HasKey FontFamily = 'True
+
+instance ToKey FontSize where
+ toKey = "font_size"
+ type HasKey FontSize = 'True
+
+instance ToKey FontStyle where
+ toKey = "font_style"
+ type HasKey FontStyle = 'True
+
+instance ToKey FontVariant where
+ toKey = "font_variant"
+ type HasKey FontVariant = 'True
+
+instance ToKey FontWeight where
+ toKey = "font_weight"
+ type HasKey FontWeight = 'True
+
+instance ToKey TextColor where
+ toKey = "text_color"
+ type HasKey TextColor = 'True
+
+instance ToKey TextDecoration where
+ toKey = "text_decoration"
+ type HasKey TextDecoration = 'True
+
+instance ToKey DescriptionWidth where
+ toKey = "description_width"
+ type HasKey DescriptionWidth = 'True
+
+instance ToKey BarColor where
+ toKey = "bar_color"
+ type HasKey BarColor = 'True
+
+instance ToKey HandleColor where
+ toKey = "handle_color"
+ type HasKey HandleColor = 'True
+
+instance ToKey ButtonWidth where
+ toKey = "button_width"
+ type HasKey ButtonWidth = 'True
+
+instance ToKey Target where
+ toKey = "target"
+ type HasKey Target = 'True
+
+instance ToKey Source where
+ toKey = "source"
+ type HasKey Source = 'True
+
+instance ToKey MsgID where
+ toKey = "msg_id"
+ type HasKey MsgID = 'True
+
+instance ToKey Outputs where
+ toKey = "outputs"
+ type HasKey Outputs = 'True
+
+instance ToKey Style where
+ toKey = "style"
+ type HasKey Style = 'True
+
+-- Layout fields
+instance ToKey LAlignContent where
+ toKey = "align_content"
+ type HasKey LAlignContent = 'True
+
+instance ToKey LAlignItems where
+ toKey = "align_items"
+ type HasKey LAlignItems = 'True
+
+instance ToKey LAlignSelf where
+ toKey = "align_self"
+ type HasKey LAlignSelf = 'True
+
+instance ToKey LBorderBottom where
+ toKey = "border_bottom"
+ type HasKey LBorderBottom = 'True
+
+instance ToKey LBorderLeft where
+ toKey = "border_left"
+ type HasKey LBorderLeft = 'True
+
+instance ToKey LBorderRight where
+ toKey = "border_right"
+ type HasKey LBorderRight = 'True
+
+instance ToKey LBorderTop where
+ toKey = "border_top"
+ type HasKey LBorderTop = 'True
+
+instance ToKey LBottom where
+ toKey = "bottom"
+ type HasKey LBottom = 'True
+
+instance ToKey LDisplay where
+ toKey = "display"
+ type HasKey LDisplay = 'True
+
+instance ToKey LFlex where
+ toKey = "flex"
+ type HasKey LFlex = 'True
+
+instance ToKey LFlexFlow where
+ toKey = "flex_flow"
+ type HasKey LFlexFlow = 'True
+
+instance ToKey LGridArea where
+ toKey = "grid_area"
+ type HasKey LGridArea = 'True
+
+instance ToKey LGridAutoColumns where
+ toKey = "grid_auto_columns"
+ type HasKey LGridAutoColumns = 'True
+
+instance ToKey LGridAutoFlow where
+ toKey = "grid_auto_flow"
+ type HasKey LGridAutoFlow = 'True
+
+instance ToKey LGridAutoRows where
+ toKey = "grid_auto_rows"
+ type HasKey LGridAutoRows = 'True
+
+instance ToKey LGridColumn where
+ toKey = "grid_column"
+ type HasKey LGridColumn = 'True
+
+instance ToKey LGridGap where
+ toKey = "grid_gap"
+ type HasKey LGridGap = 'True
+
+instance ToKey LGridRow where
+ toKey = "grid_row"
+ type HasKey LGridRow = 'True
+
+instance ToKey LGridTemplateAreas where
+ toKey = "grid_template_areas"
+ type HasKey LGridTemplateAreas = 'True
+
+instance ToKey LGridTemplateColumns where
+ toKey = "grid_template_columns"
+ type HasKey LGridTemplateColumns = 'True
+
+instance ToKey LGridTemplateRows where
+ toKey = "grid_template_rows"
+ type HasKey LGridTemplateRows = 'True
+
+instance ToKey LHeight where
+ toKey = "height"
+ type HasKey LHeight = 'True
+
+instance ToKey LJustifyContent where
+ toKey = "justify_content"
+ type HasKey LJustifyContent = 'True
+
+instance ToKey LJustifyItems where
+ toKey = "justify_items"
+ type HasKey LJustifyItems = 'True
+
+instance ToKey LLeft where
+ toKey = "left"
+ type HasKey LLeft = 'True
+
+instance ToKey LMargin where
+ toKey = "margin"
+ type HasKey LMargin = 'True
+
+instance ToKey LMaxHeight where
+ toKey = "max_height"
+ type HasKey LMaxHeight = 'True
+
+instance ToKey LMaxWidth where
+ toKey = "max_width"
+ type HasKey LMaxWidth = 'True
+
+instance ToKey LMinHeight where
+ toKey = "min_height"
+ type HasKey LMinHeight = 'True
+
+instance ToKey LMinWidth where
+ toKey = "min_width"
+ type HasKey LMinWidth = 'True
+
+instance ToKey LObjectFit where
+ toKey = "object_fit"
+ type HasKey LObjectFit = 'True
+
+instance ToKey LObjectPosition where
+ toKey = "object_position"
+ type HasKey LObjectPosition = 'True
+
+instance ToKey LOrder where
+ toKey = "order"
+ type HasKey LOrder = 'True
+
+instance ToKey LOverflow where
+ toKey = "overflow"
+ type HasKey LOverflow = 'True
+
+instance ToKey LPadding where
+ toKey = "padding"
+ type HasKey LPadding = 'True
+
+instance ToKey LRight where
+ toKey = "right"
+ type HasKey LRight = 'True
+
+instance ToKey LTop where
+ toKey = "top"
+ type HasKey LTop = 'True
+
+instance ToKey LVisibility where
+ toKey = "visibility"
+ type HasKey LVisibility = 'True
+
+instance ToKey LWidth where
+ toKey = "width"
+ type HasKey LWidth = 'True
+
+
+hasKey :: forall a. ToKey a => Bool
+hasKey = toKey @a /= ""
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Combobox.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Combobox.hs
index 70924cb4..6fdad84f 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Combobox.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Combobox.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -16,7 +17,7 @@ module IHaskell.Display.Widgets.String.Combobox
import Prelude
import Control.Monad (when)
-import Data.Aeson
+import Data.Aeson hiding (Options)
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
@@ -30,7 +31,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'ComboboxWidget' represents a Combobox widget from IPython.html.widgets.
-type ComboboxWidget = IPythonWidget 'ComboboxType
+type ComboboxWidget = IPythonWidget ComboboxType
-- | Create a new Combobox widget
mkCombobox :: IO ComboboxWidget
@@ -41,8 +42,8 @@ mkCombobox = do
dstyle <- mkDescriptionStyle
let txtWidget = defaultTextWidget "ComboboxView" "ComboboxModel" layout $ StyleWidget dstyle
- boxWidget = (Options =:: [])
- :& (EnsureOption =:: False)
+ boxWidget = (F @Options =:: [])
+ :& (F @EnsureOption =:: False)
:& RNil
widgetState = WidgetState $ txtWidget <+> boxWidget
@@ -61,7 +62,7 @@ instance IHaskellWidget ComboboxWidget where
-- Two possibilities: 1. content -> event -> "submit" 2. sync_data -> value ->
comm tw val _ = do
case nestedObjectLookup val ["state", "value"] of
- Just (String value) -> setField' tw StringValue value >> triggerChange tw
+ Just (String value) -> setField' @StringValue tw value >> triggerChange tw
_ -> pure ()
case nestedObjectLookup val ["content", "event"] of
Just (String event) -> when (event == "submit") $ triggerSubmit tw
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs
index faddc424..7f930f74 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTML.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'HTMLWidget' represents a HTML widget from IPython.html.widgets.
-type HTMLWidget = IPythonWidget 'HTMLType
+type HTMLWidget = IPythonWidget HTMLType
-- | Create a new HTML widget
mkHTML :: IO HTMLWidget
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTMLMath.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTMLMath.hs
index 2235182e..80728ebc 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTMLMath.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/HTMLMath.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'HTMLMathWidget' represents a HTML Math widget from IPython.html.widgets.
-type HTMLMathWidget = IPythonWidget 'HTMLMathType
+type HTMLMathWidget = IPythonWidget HTMLMathType
-- | Create a new HTML widget
mkHTMLMath :: IO HTMLMathWidget
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Label.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Label.hs
index 5489a8ec..9a3b8fbe 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Label.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Label.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'LabelWidget' represents a Label widget from IPython.html.widgets.
-type LabelWidget = IPythonWidget 'LabelType
+type LabelWidget = IPythonWidget LabelType
-- | Create a new Label widget
mkLabel :: IO LabelWidget
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Password.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Password.hs
index 87d152ed..8d24f67a 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Password.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Password.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'PasswordWidget' represents a Password widget from IPython.html.widgets.
-type PasswordWidget = IPythonWidget 'PasswordType
+type PasswordWidget = IPythonWidget PasswordType
-- | Create a new Password widget
mkPassword :: IO PasswordWidget
@@ -55,8 +56,8 @@ instance IHaskellWidget PasswordWidget where
getCommUUID = uuid
comm tw val _ = do
case nestedObjectLookup val ["state", "value"] of
- Just (String value) -> setField' tw StringValue value >> triggerChange tw
+ Just (String value) -> setField' @StringValue tw value >> triggerChange tw
_ -> pure ()
case nestedObjectLookup val ["content", "event"] of
Just (String event) -> when (event == "submit") $ triggerSubmit tw
- _ -> pure ()
\ No newline at end of file
+ _ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Text.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Text.hs
index 6493f001..f8d7a7b2 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Text.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/Text.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'TextWidget' represents a Text widget from IPython.html.widgets.
-type TextWidget = IPythonWidget 'TextType
+type TextWidget = IPythonWidget TextType
-- | Create a new Text widget
mkText :: IO TextWidget
@@ -56,7 +57,7 @@ instance IHaskellWidget TextWidget where
-- Two possibilities: 1. content -> event -> "submit" 2. state -> value ->
comm tw val _ = do
case nestedObjectLookup val ["state", "value"] of
- Just (String value) -> setField' tw StringValue value >> triggerChange tw
+ Just (String value) -> setField' @StringValue tw value >> triggerChange tw
_ -> pure ()
case nestedObjectLookup val ["content", "event"] of
Just (String event) -> when (event == "submit") $ triggerSubmit tw
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs
index 27aafdf3..69aabecd 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/String/TextArea.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -29,7 +30,7 @@ import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
-- | A 'TextArea' represents a Textarea widget from IPython.html.widgets.
-type TextArea = IPythonWidget 'TextAreaType
+type TextArea = IPythonWidget TextAreaType
-- | Create a new TextArea widget
mkTextArea :: IO TextArea
@@ -40,10 +41,10 @@ mkTextArea = do
dstyle <- mkDescriptionStyle
let strAttrs = defaultStringWidget "TextareaView" "TextareaModel" layout $ StyleWidget dstyle
- wgtAttrs = (Rows =:: Nothing)
- :& (Disabled =:: False)
- :& (ContinuousUpdate =:: True)
- :& (ChangeHandler =:: return ())
+ wgtAttrs = (F @Rows =:: Nothing)
+ :& (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @ChangeHandler =:: return ())
:& RNil
widgetState = WidgetState $ strAttrs <+> wgtAttrs
@@ -62,6 +63,6 @@ instance IHaskellWidget TextArea where
comm widget val _ =
case nestedObjectLookup val ["state", "value"] of
Just (String value) -> do
- void $ setField' widget StringValue value
+ void $ setField' @StringValue widget value
triggerChange widget
_ -> pure ()
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs
index 9f5235b7..728e5d11 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ButtonStyle.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -24,10 +25,10 @@ import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
-import IHaskell.Display.Widgets.Common
+import IHaskell.Display.Widgets.Common as C
-- | A 'ButtonStyle' represents a Button Style from IPython.html.widgets.
-type ButtonStyle = IPythonWidget 'ButtonStyleType
+type ButtonStyle = IPythonWidget ButtonStyleType
-- | Create a new button style
mkButtonStyle :: IO ButtonStyle
@@ -35,14 +36,14 @@ mkButtonStyle = do
wid <- U.random
let stl = defaultStyleWidget "ButtonStyleModel"
- but = (ButtonColor =:: Nothing)
- :& (FontFamily =:: Nothing)
- :& (FontSize =:: Nothing)
- :& (FontStyle =:: Nothing)
- :& (FontVariant =:: Nothing)
- :& (FontWeight =:: DefaultWeight)
- :& (TextColor =:: Nothing)
- :& (TextDecoration =:: Nothing)
+ but = (F @ButtonColor =:: Nothing)
+ :& (F @FontFamily =:: Nothing)
+ :& (F @FontSize =:: Nothing)
+ :& (F @FontStyle =:: Nothing)
+ :& (F @FontVariant =:: Nothing)
+ :& (F @FontWeight =:: DefaultWeight)
+ :& (F @TextColor =:: Nothing)
+ :& (F @TextDecoration =:: Nothing)
:& RNil
btnStlState = WidgetState (stl <+> but)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/DescriptionStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/DescriptionStyle.hs
index e5660d05..8b0c9278 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/DescriptionStyle.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/DescriptionStyle.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -25,7 +26,7 @@ import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
-- | A 'DescriptionStyle' represents a Button Style from IPython.html.widgets.
-type DescriptionStyle = IPythonWidget 'DescriptionStyleType
+type DescriptionStyle = IPythonWidget DescriptionStyleType
-- | Create a new button style
mkDescriptionStyle :: IO DescriptionStyle
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ProgressStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ProgressStyle.hs
index 24c5e2e4..7cdf0c11 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ProgressStyle.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ProgressStyle.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'ProgressStyle' represents a Button Style from IPython.html.widgets.
-type ProgressStyle = IPythonWidget 'ProgressStyleType
+type ProgressStyle = IPythonWidget ProgressStyleType
-- | Create a new button style
mkProgressStyle :: IO ProgressStyle
@@ -35,7 +36,7 @@ mkProgressStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "ProgressStyleModel"
- but = (BarColor =:: Nothing)
+ but = (F @BarColor =:: Nothing)
:& RNil
btnStlState = WidgetState (stl <+> but)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/SliderStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/SliderStyle.hs
index 48b276ba..a5d68f26 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/SliderStyle.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/SliderStyle.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'SliderStyle' represents a Button Style from IPython.html.widgets.
-type SliderStyle = IPythonWidget 'SliderStyleType
+type SliderStyle = IPythonWidget SliderStyleType
-- | Create a new button style
mkSliderStyle :: IO SliderStyle
@@ -35,7 +36,7 @@ mkSliderStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "SliderStyleModel"
- but = (HandleColor =:: Nothing)
+ but = (F @HandleColor =:: Nothing)
:& RNil
btnStlState = WidgetState (stl <+> but)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ToggleButtonsStyle.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ToggleButtonsStyle.hs
index 240bf9ff..364ab618 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ToggleButtonsStyle.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Style/ToggleButtonsStyle.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -27,7 +28,7 @@ import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
-- | A 'ToggleButtonsStyle' represents a Button Style from IPython.html.widgets.
-type ToggleButtonsStyle = IPythonWidget 'ToggleButtonsStyleType
+type ToggleButtonsStyle = IPythonWidget ToggleButtonsStyleType
-- | Create a new button style
mkToggleButtonsStyle :: IO ToggleButtonsStyle
@@ -35,8 +36,8 @@ mkToggleButtonsStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "ToggleButtonsStyleModel"
- but = (ButtonWidth =:: "")
- :& (FontWeight =:: DefaultWeight)
+ but = (F @ButtonWidth =:: "")
+ :& (F @FontWeight =:: DefaultWeight)
:& RNil
btnStlState = WidgetState (stl <+> but)
diff --git a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
index 8a9f1fed..b4cd37db 100644
--- a/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+++ b/ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
@@ -17,37 +17,30 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeApplications #-}
+{-# LANGUAGE AllowAmbiguousTypes #-}
+{-# LANGUAGE PatternSynonyms #-}
-- | This module houses all the type-trickery needed to make widgets happen.
--
--- All widgets have a corresponding 'WidgetType', and some fields/attributes/properties as defined
--- by the 'WidgetFields' type-family.
+-- All widgets have a data type without a constructor defined later in this file. Some
+-- fields/attributes/properties as defined by the 'WidgetFields' type-family.
--
-- Each widget field corresponds to a concrete haskell type, as given by the 'FieldType'
-- type-family.
--
-- Vinyl records are used to wrap together widget fields into a single 'WidgetState'.
--
--- Singletons are used as a way to represent the promoted types of kind Field. For example:
+-- Users pass types by visible type application.
--
--- @
--- SViewName :: SField ViewName
--- @
---
--- This allows the user to pass the type 'ViewName' without using Data.Proxy. In essence, a
--- singleton is the only inhabitant (other than bottom) of a promoted type. Single element set/type
--- == singleton.
---
--- It also allows the record to wrap values of properties with information about their Field type. A
--- vinyl record is represented as @Rec f ts@, which means that a record is a list of @f x@, where
+-- A vinyl record is represented as @Rec f ts@, which means that a record is a list of @f x@, where
-- @x@ is a type present in the type-level list @ts@. Thus a 'WidgetState' is essentially a list of
--- field properties wrapped together with the corresponding promoted Field type. See ('=::') for
--- more.
+-- field properties wrapped together with the corresponding field name. See ('=::') for more.
--
--- The properties function can be used to view all the @Field@s associated with a widget object.
+-- The properties function can be used to view all the fields associated with a widget object.
--
--- Attributes are represented by the @Attr@ data type, which holds the value of a field, along with
--- the actual @Field@ object and a function to verify validity of changes to the value.
+-- Attributes are represented by the @Attr@ data type, which holds the value of a field and a
+-- function to verify validity of changes to the value.
--
-- The IPython widgets expect state updates of the form {"property": value}, where an empty string
-- for numeric values is ignored by the frontend and the default value is used instead. Some numbers
@@ -62,6 +55,9 @@
--
-- Widgets are not able to do console input, the reason for that can be found in the messaging
-- specification.
+--
+-- Widgets and fields are open. You can create a custom widget by implementing WidgetFields and new
+-- fields by implementing FieldType and ToKey.
module IHaskell.Display.Widgets.Types where
import Control.Applicative ((<$>))
@@ -70,10 +66,12 @@ import Control.Monad (unless, join, when, void,mzero)
import Data.IORef (IORef, readIORef, modifyIORef)
import Data.String
import Data.Text (Text, pack)
-import Data.Typeable (Typeable, TypeRep, typeOf)
+import Data.Typeable (Typeable, TypeRep, typeOf, typeRep, Proxy(..))
import System.IO.Error
import System.Posix.IO
import Text.Printf (printf)
+import GHC.Exts (Constraint)
+import GHC.TypeLits
import Data.Aeson hiding (pairs)
import Data.Aeson.Types (Pair)
@@ -86,22 +84,8 @@ import Data.Vinyl.Recursive ((<+>), recordToList, reifyConstraint, rma
import Data.Vinyl (Rec(..), (<+>), recordToList, reifyConstraint, rmap, Dict(..))
#endif
import Data.Vinyl.Functor (Compose(..), Const(..))
-import Data.Vinyl.Lens (rget, rput, type (∈))
-import Data.Vinyl.TypeLevel (RecAll)
-
-#if MIN_VERSION_singletons(3,0,0)
-import Data.List.Singletons
-#elif MIN_VERSION_singletons(2,4,0)
-import Data.Singletons.Prelude.List
-#else
-import Data.Singletons.Prelude ((:++))
-#endif
-
-#if MIN_VERSION_singletons(3,0,0)
-import Data.Singletons.Base.TH
-#else
-import Data.Singletons.TH
-#endif
+import Data.Vinyl.Lens (rget, rput, RElem)
+import Data.Vinyl.TypeLevel (RecAll, RIndex)
import Data.Text.Lazy (unpack)
import Data.Text.Lazy.Encoding
@@ -113,169 +97,171 @@ import IHaskell.Display (IHaskellWidget(..), IHaskellDisplay(..), Disp
import IHaskell.IPython.Types (StreamType(..))
import IHaskell.IPython.Message.UUID
-import IHaskell.Display.Widgets.Singletons (Field, SField, toKey, HasKey)
+import IHaskell.Display.Widgets.Singletons (ToKey, toKey, HasKey)
+import IHaskell.Display.Widgets.Singletons
import qualified IHaskell.Display.Widgets.Singletons as S
import IHaskell.Display.Widgets.Common
-#if MIN_VERSION_singletons(2,4,0)
--- Versions of the "singletons" package are tightly tied to the GHC version.
--- Singletons versions 2.3.* and earlier used the type level operator ':++'
--- for appending type level lists while 2.4.* and latter use the normal value
--- level list append operator '++'.
--- To maintain compatibility across GHC versions we keep using the ':++'
--- operator for now.
-type (a :++ b) = a ++ b
-#endif
+type RElemOf r rs = RElem r rs (RIndex r rs)
+
+-- | F for field. Nicer than Proxy.
+-- Used only in infix functions since @f := val is not allowed.
+data F a = F
+
+-- Define the type family for appending two type-level lists
+type family (:++) (xs :: [a]) (ys :: [a]) :: [a] where
+ '[] :++ ys = ys
+ (x ': xs) :++ ys = x ': (xs :++ ys)
-- Classes from IPython's widget hierarchy. Defined as such to reduce code duplication.
-type CoreWidgetClass = ['S.ViewModule, 'S.ViewModuleVersion, 'S.ModelModule, 'S.ModelModuleVersion ]
+type CoreWidgetClass = '[S.ViewModule, S.ViewModuleVersion, S.ModelModule, S.ModelModuleVersion ]
-type DOMWidgetClass = ['S.ModelName, 'S.ViewName, 'S.DOMClasses, 'S.Tabbable, 'S.Tooltip, 'S.Layout, 'S.DisplayHandler]
+type DOMWidgetClass = '[S.ModelName, S.ViewName, S.DOMClasses, S.Tabbable, S.Tooltip, S.Layout, S.DisplayHandler]
-type StyleWidgetClass = ['S.ModelName, 'S.ViewName] :++ CoreWidgetClass
+type StyleWidgetClass = '[S.ModelName, S.ViewName] :++ CoreWidgetClass
-type DescriptionWidgetClass = CoreWidgetClass :++ DOMWidgetClass :++ ['S.Description,'S.DescriptionAllowHtml,'S.Style]
+type DescriptionWidgetClass = CoreWidgetClass :++ DOMWidgetClass :++ '[S.Description,S.DescriptionAllowHtml,S.Style]
-type StringClass = DescriptionWidgetClass :++ ['S.StringValue, 'S.Placeholder]
+type StringClass = DescriptionWidgetClass :++ '[S.StringValue, S.Placeholder]
-type TextClass = StringClass :++ [ 'S.Disabled, 'S.ContinuousUpdate, 'S.SubmitHandler, 'S.ChangeHandler]
+type TextClass = StringClass :++ '[ S.Disabled, S.ContinuousUpdate, S.SubmitHandler, S.ChangeHandler]
-type BoolClass = DescriptionWidgetClass :++ ['S.BoolValue, 'S.Disabled, 'S.ChangeHandler]
+type BoolClass = DescriptionWidgetClass :++ '[S.BoolValue, S.Disabled, S.ChangeHandler]
-type SelectionClass = DescriptionWidgetClass :++ ['S.OptionsLabels, 'S.OptionalIndex, 'S.Disabled, 'S.SelectionHandler]
+type SelectionClass = DescriptionWidgetClass :++ '[S.OptionsLabels, S.OptionalIndex, S.Disabled, S.SelectionHandler]
-type SelectionNonemptyClass = DescriptionWidgetClass :++ ['S.OptionsLabels, 'S.Index, 'S.Disabled, 'S.SelectionHandler]
+type SelectionNonemptyClass = DescriptionWidgetClass :++ '[S.OptionsLabels, S.Index, S.Disabled, S.SelectionHandler]
-type MultipleSelectionClass = DescriptionWidgetClass :++ ['S.OptionsLabels, 'S.Indices, 'S.Disabled, 'S.SelectionHandler]
+type MultipleSelectionClass = DescriptionWidgetClass :++ '[S.OptionsLabels, S.Indices, S.Disabled, S.SelectionHandler]
-type IntClass = DescriptionWidgetClass :++ [ 'S.IntValue, 'S.ChangeHandler ]
+type IntClass = DescriptionWidgetClass :++ '[ S.IntValue, S.ChangeHandler ]
-type BoundedIntClass = IntClass :++ ['S.MaxInt, 'S.MinInt]
+type BoundedIntClass = IntClass :++ '[S.MaxInt, S.MinInt]
-type IntRangeClass = IntClass :++ ['S.IntPairValue, 'S.LowerInt, 'S.UpperInt]
+type IntRangeClass = IntClass :++ '[S.IntPairValue, S.LowerInt, S.UpperInt]
-type BoundedIntRangeClass = IntRangeClass :++ ['S.MaxInt, 'S.MinInt]
+type BoundedIntRangeClass = IntRangeClass :++ '[S.MaxInt, S.MinInt]
-type FloatClass = DescriptionWidgetClass :++ [ 'S.FloatValue, 'S.ChangeHandler ]
+type FloatClass = DescriptionWidgetClass :++ '[ S.FloatValue, S.ChangeHandler ]
-type BoundedFloatClass = FloatClass :++ ['S.MinFloat, 'S.MaxFloat]
+type BoundedFloatClass = FloatClass :++ '[S.MinFloat, S.MaxFloat]
-type BoundedLogFloatClass = FloatClass :++ [ 'S.MinFloat, 'S.MaxFloat, 'S.BaseFloat ]
+type BoundedLogFloatClass = FloatClass :++ '[ S.MinFloat, S.MaxFloat, S.BaseFloat ]
-type FloatRangeClass = FloatClass :++ '[ 'S.FloatPairValue ]
+type FloatRangeClass = FloatClass :++ '[ S.FloatPairValue ]
-type BoundedFloatRangeClass = FloatRangeClass :++ ['S.StepFloat, 'S.MinFloat, 'S.MaxFloat]
+type BoundedFloatRangeClass = FloatRangeClass :++ '[S.StepFloat, S.MinFloat, S.MaxFloat]
-type BoxClass = CoreWidgetClass :++ DOMWidgetClass :++ ['S.Children, 'S.BoxStyle]
+type BoxClass = CoreWidgetClass :++ DOMWidgetClass :++ '[S.Children, S.BoxStyle]
-type SelectionContainerClass = BoxClass :++ ['S.Titles, 'S.SelectedIndex, 'S.ChangeHandler]
+type SelectionContainerClass = BoxClass :++ '[S.Titles, S.SelectedIndex, S.ChangeHandler]
-type MediaClass = CoreWidgetClass :++ DOMWidgetClass :++ '[ 'S.BSValue ]
+type MediaClass = CoreWidgetClass :++ DOMWidgetClass :++ '[ S.BSValue ]
-type DescriptionStyleClass = StyleWidgetClass :++ '[ 'S.DescriptionWidth ]
+type DescriptionStyleClass = StyleWidgetClass :++ '[ S.DescriptionWidth ]
-type LinkClass = CoreWidgetClass :++ ['S.ModelName, 'S.Target, 'S.Source]
+type LinkClass = CoreWidgetClass :++ '[S.ModelName, S.Target, S.Source]
-- Types associated with Fields.
-type family FieldType (f :: Field) :: *
+type family FieldType f :: *
-type instance FieldType 'S.ViewModule = Text
-type instance FieldType 'S.ViewModuleVersion = Text
-type instance FieldType 'S.ViewName = Text
-type instance FieldType 'S.ModelModule = Text
-type instance FieldType 'S.ModelModuleVersion = Text
-type instance FieldType 'S.ModelName = Text
-type instance FieldType 'S.Layout = IPythonWidget 'LayoutType
-type instance FieldType 'S.DisplayHandler = IO ()
-type instance FieldType 'S.DOMClasses = [Text]
-type instance FieldType 'S.Width = PixCount
-type instance FieldType 'S.Height = PixCount
-type instance FieldType 'S.Description = Text
-type instance FieldType 'S.DescriptionAllowHtml = Maybe Bool
-type instance FieldType 'S.ClickHandler = IO ()
-type instance FieldType 'S.SubmitHandler = IO ()
-type instance FieldType 'S.Disabled = Bool
-type instance FieldType 'S.StringValue = Text
-type instance FieldType 'S.Placeholder = Text
-type instance FieldType 'S.Tabbable = Maybe Bool
-type instance FieldType 'S.Tooltip = Maybe Text
-type instance FieldType 'S.Icon = Text
-type instance FieldType 'S.ButtonStyle = ButtonStyleValue
-type instance FieldType 'S.BSValue = JSONByteString
-type instance FieldType 'S.ImageFormat = ImageFormatValue
-type instance FieldType 'S.BoolValue = Bool
-type instance FieldType 'S.OptionsLabels = [Text]
-type instance FieldType 'S.Index = Integer
-type instance FieldType 'S.OptionalIndex = Maybe Integer
-type instance FieldType 'S.SelectionHandler = IO ()
-type instance FieldType 'S.Tooltips = [Text]
-type instance FieldType 'S.Icons = [Text]
-type instance FieldType 'S.Indices = [Integer]
-type instance FieldType 'S.IntValue = Integer
-type instance FieldType 'S.StepInt = Maybe Integer
-type instance FieldType 'S.MinInt = Integer
-type instance FieldType 'S.MaxInt = Integer
-type instance FieldType 'S.LowerInt = Integer
-type instance FieldType 'S.UpperInt = Integer
-type instance FieldType 'S.IntPairValue = (Integer, Integer)
-type instance FieldType 'S.Orientation = OrientationValue
-type instance FieldType 'S.BaseFloat = Double
-type instance FieldType 'S.ReadOut = Bool
-type instance FieldType 'S.ReadOutFormat = Text
-type instance FieldType 'S.BarStyle = BarStyleValue
-type instance FieldType 'S.FloatValue = Double
-type instance FieldType 'S.StepFloat = Maybe Double
-type instance FieldType 'S.MinFloat = Double
-type instance FieldType 'S.MaxFloat = Double
-type instance FieldType 'S.LowerFloat = Double
-type instance FieldType 'S.UpperFloat = Double
-type instance FieldType 'S.FloatPairValue = (Double, Double)
-type instance FieldType 'S.ChangeHandler = IO ()
-type instance FieldType 'S.Children = [ChildWidget]
-type instance FieldType 'S.BoxStyle = BoxStyleValue
-type instance FieldType 'S.Titles = [Text]
-type instance FieldType 'S.SelectedIndex = Maybe Integer
-type instance FieldType 'S.ReadOutMsg = Text
-type instance FieldType 'S.Indent = Bool
-type instance FieldType 'S.ContinuousUpdate = Bool
-type instance FieldType 'S.Rows = Maybe Integer
-type instance FieldType 'S.AudioFormat = AudioFormatValue
-type instance FieldType 'S.VideoFormat = VideoFormatValue
-type instance FieldType 'S.AutoPlay = Bool
-type instance FieldType 'S.Loop = Bool
-type instance FieldType 'S.Controls = Bool
-type instance FieldType 'S.Options = [Text]
-type instance FieldType 'S.EnsureOption = Bool
-type instance FieldType 'S.Playing = Bool
-type instance FieldType 'S.Repeat = Bool
-type instance FieldType 'S.Interval = Integer
-type instance FieldType 'S.ShowRepeat = Bool
-type instance FieldType 'S.Concise = Bool
-type instance FieldType 'S.DateValue = Date
-type instance FieldType 'S.Pressed = Bool
-type instance FieldType 'S.Name = Text
-type instance FieldType 'S.Mapping = Text
-type instance FieldType 'S.Connected = Bool
-type instance FieldType 'S.Timestamp = Double
-type instance FieldType 'S.Buttons = [IPythonWidget 'ControllerButtonType]
-type instance FieldType 'S.Axes = [IPythonWidget 'ControllerAxisType]
-type instance FieldType 'S.ButtonColor = Maybe String
-type instance FieldType 'S.FontFamily = Maybe String
-type instance FieldType 'S.FontSize = Maybe String
-type instance FieldType 'S.FontStyle = Maybe String
-type instance FieldType 'S.FontVariant = Maybe String
-type instance FieldType 'S.FontWeight = FontWeightValue
-type instance FieldType 'S.TextColor = Maybe String
-type instance FieldType 'S.TextDecoration = Maybe String
-type instance FieldType 'S.DescriptionWidth = String
-type instance FieldType 'S.BarColor = Maybe String
-type instance FieldType 'S.HandleColor = Maybe String
-type instance FieldType 'S.ButtonWidth = String
-type instance FieldType 'S.Target = WidgetFieldPair
-type instance FieldType 'S.Source = WidgetFieldPair
-type instance FieldType 'S.MsgID = Text
-type instance FieldType 'S.Outputs = [OutputMsg]
-type instance FieldType 'S.Style = StyleWidget
+type instance FieldType S.ViewModule = Text
+type instance FieldType S.ViewModuleVersion = Text
+type instance FieldType S.ViewName = Text
+type instance FieldType S.ModelModule = Text
+type instance FieldType S.ModelModuleVersion = Text
+type instance FieldType S.ModelName = Text
+type instance FieldType S.Layout = IPythonWidget LayoutType
+type instance FieldType S.DisplayHandler = IO ()
+type instance FieldType S.DOMClasses = [Text]
+type instance FieldType S.Width = PixCount
+type instance FieldType S.Height = PixCount
+type instance FieldType S.Description = Text
+type instance FieldType S.DescriptionAllowHtml = Maybe Bool
+type instance FieldType S.ClickHandler = IO ()
+type instance FieldType S.SubmitHandler = IO ()
+type instance FieldType S.Disabled = Bool
+type instance FieldType S.StringValue = Text
+type instance FieldType S.Placeholder = Text
+type instance FieldType S.Tabbable = Maybe Bool
+type instance FieldType S.Tooltip = Maybe Text
+type instance FieldType S.Icon = Text
+type instance FieldType S.ButtonStyleField = ButtonStyleValue
+type instance FieldType S.BSValue = JSONByteString
+type instance FieldType S.ImageFormat = ImageFormatValue
+type instance FieldType S.BoolValue = Bool
+type instance FieldType S.OptionsLabels = [Text]
+type instance FieldType S.Index = Integer
+type instance FieldType S.OptionalIndex = Maybe Integer
+type instance FieldType S.SelectionHandler = IO ()
+type instance FieldType S.Tooltips = [Text]
+type instance FieldType S.Icons = [Text]
+type instance FieldType S.Indices = [Integer]
+type instance FieldType S.IntValue = Integer
+type instance FieldType S.StepInt = Maybe Integer
+type instance FieldType S.MinInt = Integer
+type instance FieldType S.MaxInt = Integer
+type instance FieldType S.LowerInt = Integer
+type instance FieldType S.UpperInt = Integer
+type instance FieldType S.IntPairValue = (Integer, Integer)
+type instance FieldType S.Orientation = OrientationValue
+type instance FieldType S.BaseFloat = Double
+type instance FieldType S.ReadOut = Bool
+type instance FieldType S.ReadOutFormat = Text
+type instance FieldType S.BarStyle = BarStyleValue
+type instance FieldType S.FloatValue = Double
+type instance FieldType S.StepFloat = Maybe Double
+type instance FieldType S.MinFloat = Double
+type instance FieldType S.MaxFloat = Double
+type instance FieldType S.LowerFloat = Double
+type instance FieldType S.UpperFloat = Double
+type instance FieldType S.FloatPairValue = (Double, Double)
+type instance FieldType S.ChangeHandler = IO ()
+type instance FieldType S.Children = [ChildWidget]
+type instance FieldType S.BoxStyle = BoxStyleValue
+type instance FieldType S.Titles = [Text]
+type instance FieldType S.SelectedIndex = Maybe Integer
+type instance FieldType S.ReadOutMsg = Text
+type instance FieldType S.Indent = Bool
+type instance FieldType S.ContinuousUpdate = Bool
+type instance FieldType S.Rows = Maybe Integer
+type instance FieldType S.AudioFormat = AudioFormatValue
+type instance FieldType S.VideoFormat = VideoFormatValue
+type instance FieldType S.AutoPlay = Bool
+type instance FieldType S.Loop = Bool
+type instance FieldType S.Controls = Bool
+type instance FieldType S.Options = [Text]
+type instance FieldType S.EnsureOption = Bool
+type instance FieldType S.Playing = Bool
+type instance FieldType S.Repeat = Bool
+type instance FieldType S.Interval = Integer
+type instance FieldType S.ShowRepeat = Bool
+type instance FieldType S.Concise = Bool
+type instance FieldType S.DateValue = Date
+type instance FieldType S.Pressed = Bool
+type instance FieldType S.Name = Text
+type instance FieldType S.Mapping = Text
+type instance FieldType S.Connected = Bool
+type instance FieldType S.Timestamp = Double
+type instance FieldType S.Buttons = [IPythonWidget ControllerButtonType]
+type instance FieldType S.Axes = [IPythonWidget ControllerAxisType]
+type instance FieldType S.ButtonColor = Maybe String
+type instance FieldType S.FontFamily = Maybe String
+type instance FieldType S.FontSize = Maybe String
+type instance FieldType S.FontStyle = Maybe String
+type instance FieldType S.FontVariant = Maybe String
+type instance FieldType S.FontWeight = FontWeightValue
+type instance FieldType S.TextColor = Maybe String
+type instance FieldType S.TextDecoration = Maybe String
+type instance FieldType S.DescriptionWidth = String
+type instance FieldType S.BarColor = Maybe String
+type instance FieldType S.HandleColor = Maybe String
+type instance FieldType S.ButtonWidth = String
+type instance FieldType S.Target = WidgetFieldPair
+type instance FieldType S.Source = WidgetFieldPair
+type instance FieldType S.MsgID = Text
+type instance FieldType S.Outputs = [OutputMsg]
+type instance FieldType S.Style = StyleWidget
-- | Can be used to put different widgets in a list. Useful for dealing with children widgets.
data ChildWidget = forall w. RecAll Attr (WidgetFields w) ToPairs => ChildWidget (IPythonWidget w)
@@ -312,159 +298,164 @@ instance CustomBounded Double where
upperBound = fromIntegral (maxBound :: Int16)
-- | This type only fits if the field is among the widget's fields, and it has a key
-data WidgetFieldPair = forall w f. (f ∈ WidgetFields w, HasKey f ~ 'True, RecAll Attr (WidgetFields w) ToPairs) => WidgetFieldPair (IPythonWidget w) (SField f) | EmptyWT
+data WidgetFieldPair = forall w f. (RElemOf f (WidgetFields w), ToKey f, HasKey f ~ 'True, RecAll Attr (WidgetFields w) ToPairs)
+ => WidgetFieldPair (IPythonWidget w) (Proxy f) | EmptyWT
instance ToJSON WidgetFieldPair where
toJSON EmptyWT = Null
- toJSON (WidgetFieldPair w f) = toJSON [toJSON w, toJSON $ pack $ toKey $ fromSing f]
+ toJSON (WidgetFieldPair w (Proxy :: Proxy f)) = toJSON [toJSON w, toJSON $ pack $ toKey @f]
--- Different types of widgets. Every widget in IPython has a corresponding WidgetType
-data WidgetType = ButtonType
- | ColorPickerType
- | DatePickerType
- | AudioType
- | ImageType
- | VideoType
- | OutputType
- | ComboboxType
- | HTMLType
- | HTMLMathType
- | LabelType
- | PasswordType
- | TextType
- | TextAreaType
- | CheckBoxType
- | ToggleButtonType
- | ValidType
- | DropdownType
- | RadioButtonsType
- | SelectType
- | SelectionSliderType
- | SelectionRangeSliderType
- | ToggleButtonsType
- | SelectMultipleType
- | IntTextType
- | BoundedIntTextType
- | IntSliderType
- | PlayType
- | IntProgressType
- | IntRangeSliderType
- | FloatTextType
- | BoundedFloatTextType
- | FloatSliderType
- | FloatLogSliderType
- | FloatProgressType
- | FloatRangeSliderType
- | BoxType
- | GridBoxType
- | HBoxType
- | VBoxType
- | AccordionType
- | TabType
- | StackedType
- | ControllerButtonType
- | ControllerAxisType
- | ControllerType
- | LinkType
- | DirectionalLinkType
- | LayoutType
- | ButtonStyleType
- | DescriptionStyleType
- | ProgressStyleType
- | SliderStyleType
- | ToggleButtonsStyleType
+-- Different types of widgets. Every widget in IPython has a corresponding widget type.
+data ButtonType
+data ColorPickerType
+data DatePickerType
+data AudioType
+data ImageType
+data VideoType
+data OutputType
+data HTMLType
+data HTMLMathType
+data ComboboxType
+data LabelType
+data PasswordType
+data TextType
+data TextAreaType
+data CheckBoxType
+data ToggleButtonType
+data ValidType
+data DropdownType
+data RadioButtonsType
+data SelectType
+data SelectionSliderType
+data SelectionRangeSliderType
+data ToggleButtonsType
+data SelectMultipleType
+data IntTextType
+data BoundedIntTextType
+data IntSliderType
+data PlayType
+data IntProgressType
+data IntRangeSliderType
+data FloatTextType
+data BoundedFloatTextType
+data FloatSliderType
+data FloatLogSliderType
+data FloatProgressType
+data FloatRangeSliderType
+data BoxType
+data GridBoxType
+data HBoxType
+data VBoxType
+data AccordionType
+data TabType
+data StackedType
+data ControllerButtonType
+data ControllerAxisType
+data ControllerType
+data LinkType
+data DirectionalLinkType
+data LayoutType
+data ButtonStyleType
+data DescriptionStyleType
+data ProgressStyleType
+data SliderStyleType
+data ToggleButtonsStyleType
-- Fields associated with a widget
-type family WidgetFields (w :: WidgetType) :: [Field]
-type instance WidgetFields 'ButtonType =
- DescriptionWidgetClass :++
- ['S.Disabled, 'S.Icon, 'S.ButtonStyle,'S.ClickHandler]
-type instance WidgetFields 'ColorPickerType =
- DescriptionWidgetClass :++
- ['S.StringValue, 'S.Concise, 'S.Disabled, 'S.ChangeHandler]
-type instance WidgetFields 'DatePickerType =
- DescriptionWidgetClass :++
- ['S.DateValue, 'S.Disabled, 'S.ChangeHandler]
+type family AllToKey (xs :: [*]) :: Constraint where
+ AllToKey '[] = ()
+ AllToKey (x ': xs) = (ToKey x, Typeable x, AllToKey xs)
-type instance WidgetFields 'AudioType =
- MediaClass :++ ['S.AudioFormat, 'S.AutoPlay, 'S.Loop, 'S.Controls]
-type instance WidgetFields 'ImageType =
- MediaClass :++ ['S.ImageFormat, 'S.Width, 'S.Height]
-type instance WidgetFields 'VideoType =
- MediaClass :++ ['S.VideoFormat, 'S.Width, 'S.Height, 'S.AutoPlay, 'S.Loop, 'S.Controls]
+type family WidgetFields w :: [*]
+type instance WidgetFields ButtonType =
+ DescriptionWidgetClass :++
+ [S.Disabled, S.Icon, S.ButtonStyleField,S.ClickHandler]
+type instance WidgetFields ColorPickerType =
+ DescriptionWidgetClass :++
+ [S.StringValue, S.Concise, S.Disabled, S.ChangeHandler]
+type instance WidgetFields DatePickerType =
+ DescriptionWidgetClass :++
+ [S.DateValue, S.Disabled, S.ChangeHandler]
-type instance WidgetFields 'OutputType = DOMWidgetClass :++ ['S.ViewModule,'S.ModelModule,'S.ViewModuleVersion,'S.ModelModuleVersion,'S.MsgID,'S.Outputs]
-type instance WidgetFields 'HTMLType = StringClass
-type instance WidgetFields 'HTMLMathType = StringClass
-type instance WidgetFields 'ComboboxType = TextClass :++ [ 'S.Options, 'S.EnsureOption ]
-type instance WidgetFields 'LabelType = StringClass
-type instance WidgetFields 'PasswordType = TextClass
-type instance WidgetFields 'TextType = TextClass
+type instance WidgetFields AudioType =
+ MediaClass :++ [S.AudioFormat, S.AutoPlay, S.Loop, S.Controls]
+type instance WidgetFields ImageType =
+ MediaClass :++ [S.ImageFormat, S.Width, S.Height]
+type instance WidgetFields VideoType =
+ MediaClass :++ [S.VideoFormat, S.Width, S.Height, S.AutoPlay, S.Loop, S.Controls]
+
+type instance WidgetFields OutputType = DOMWidgetClass :++ [S.ViewModule,S.ModelModule,S.ViewModuleVersion,S.ModelModuleVersion,S.MsgID,S.Outputs]
+type instance WidgetFields HTMLType = StringClass
+type instance WidgetFields HTMLMathType = StringClass
+type instance WidgetFields ComboboxType = TextClass :++ [ S.Options, S.EnsureOption ]
+type instance WidgetFields LabelType = StringClass
+type instance WidgetFields PasswordType = TextClass
+type instance WidgetFields TextType = TextClass
-- Type level lists with a single element need both the list and the
-- constructor ticked, and a space between the open square bracket and
-- the first constructor. See https://ghc.haskell.org/trac/ghc/ticket/15601
-type instance WidgetFields 'TextAreaType =
+type instance WidgetFields TextAreaType =
StringClass :++
- [ 'S.Rows, 'S.Disabled, 'S.ContinuousUpdate, 'S.ChangeHandler]
+ [ S.Rows, S.Disabled, S.ContinuousUpdate, S.ChangeHandler]
-type instance WidgetFields 'CheckBoxType = BoolClass :++ '[ 'S.Indent ]
-type instance WidgetFields 'ToggleButtonType = BoolClass :++ ['S.Icon, 'S.ButtonStyle]
-type instance WidgetFields 'ValidType = BoolClass :++ '[ 'S.ReadOutMsg ]
-type instance WidgetFields 'DropdownType = SelectionClass
-type instance WidgetFields 'RadioButtonsType = SelectionClass
-type instance WidgetFields 'SelectType = SelectionClass :++ '[ 'S.Rows ]
-type instance WidgetFields 'SelectionSliderType = SelectionNonemptyClass :++ '[ 'S.Orientation, 'S.ReadOut, 'S.ContinuousUpdate ]
-type instance WidgetFields 'SelectionRangeSliderType = MultipleSelectionClass :++ '[ 'S.Orientation, 'S.ReadOut, 'S.ContinuousUpdate ]
-type instance WidgetFields 'ToggleButtonsType =
- SelectionClass :++ ['S.Tooltips, 'S.Icons, 'S.ButtonStyle]
-type instance WidgetFields 'SelectMultipleType = MultipleSelectionClass :++ '[ 'S.Rows ]
-type instance WidgetFields 'IntTextType = IntClass :++ [ 'S.Disabled, 'S.ContinuousUpdate, 'S.StepInt ]
-type instance WidgetFields 'BoundedIntTextType = BoundedIntClass :++ [ 'S.Disabled, 'S.ContinuousUpdate, 'S.StepInt ]
-type instance WidgetFields 'IntSliderType =
+type instance WidgetFields CheckBoxType = BoolClass :++ '[ S.Indent ]
+type instance WidgetFields ToggleButtonType = BoolClass :++ [S.Icon, S.ButtonStyleField]
+type instance WidgetFields ValidType = BoolClass :++ '[ S.ReadOutMsg ]
+type instance WidgetFields DropdownType = SelectionClass
+type instance WidgetFields RadioButtonsType = SelectionClass
+type instance WidgetFields SelectType = SelectionClass :++ '[ S.Rows ]
+type instance WidgetFields SelectionSliderType = SelectionNonemptyClass :++ '[ S.Orientation, S.ReadOut, S.ContinuousUpdate ]
+type instance WidgetFields SelectionRangeSliderType = MultipleSelectionClass :++ '[ S.Orientation, S.ReadOut, S.ContinuousUpdate ]
+type instance WidgetFields ToggleButtonsType =
+ SelectionClass :++ [S.Tooltips, S.Icons, S.ButtonStyleField]
+type instance WidgetFields SelectMultipleType = MultipleSelectionClass :++ '[ S.Rows ]
+type instance WidgetFields IntTextType = IntClass :++ [ S.Disabled, S.ContinuousUpdate, S.StepInt ]
+type instance WidgetFields BoundedIntTextType = BoundedIntClass :++ [ S.Disabled, S.ContinuousUpdate, S.StepInt ]
+type instance WidgetFields IntSliderType =
BoundedIntClass :++
- [ 'S.StepInt, 'S.Orientation, 'S.ReadOut, 'S.ReadOutFormat, 'S.ContinuousUpdate, 'S.Disabled ]
-type instance WidgetFields 'PlayType =
+ [ S.StepInt, S.Orientation, S.ReadOut, S.ReadOutFormat, S.ContinuousUpdate, S.Disabled ]
+type instance WidgetFields PlayType =
BoundedIntClass :++
- [ 'S.Playing, 'S.Repeat, 'S.Interval, 'S.StepInt, 'S.Disabled, 'S.ShowRepeat ]
-type instance WidgetFields 'IntProgressType =
- BoundedIntClass :++ ['S.Orientation, 'S.BarStyle]
-type instance WidgetFields 'IntRangeSliderType =
+ [ S.Playing, S.Repeat, S.Interval, S.StepInt, S.Disabled, S.ShowRepeat ]
+type instance WidgetFields IntProgressType =
+ BoundedIntClass :++ [S.Orientation, S.BarStyle]
+type instance WidgetFields IntRangeSliderType =
BoundedIntRangeClass :++
- ['S.StepInt, 'S.Orientation, 'S.ReadOut, 'S.ReadOutFormat, 'S.ContinuousUpdate, 'S.Disabled ]
-type instance WidgetFields 'FloatTextType = FloatClass :++ '[ 'S.Disabled, 'S.ContinuousUpdate, 'S.StepFloat ]
-type instance WidgetFields 'BoundedFloatTextType = BoundedFloatClass :++ '[ 'S.Disabled, 'S.ContinuousUpdate, 'S.StepFloat ]
-type instance WidgetFields 'FloatSliderType =
+ [S.StepInt, S.Orientation, S.ReadOut, S.ReadOutFormat, S.ContinuousUpdate, S.Disabled ]
+type instance WidgetFields FloatTextType = FloatClass :++ '[ S.Disabled, S.ContinuousUpdate, S.StepFloat ]
+type instance WidgetFields BoundedFloatTextType = BoundedFloatClass :++ '[ S.Disabled, S.ContinuousUpdate, S.StepFloat ]
+type instance WidgetFields FloatSliderType =
BoundedFloatClass :++
- ['S.StepFloat, 'S.Orientation, 'S.ReadOut, 'S.ReadOutFormat, 'S.ContinuousUpdate, 'S.Disabled ]
-type instance WidgetFields 'FloatLogSliderType =
+ [S.StepFloat, S.Orientation, S.ReadOut, S.ReadOutFormat, S.ContinuousUpdate, S.Disabled ]
+type instance WidgetFields FloatLogSliderType =
BoundedLogFloatClass :++
- ['S.StepFloat, 'S.Orientation, 'S.ReadOut, 'S.ReadOutFormat, 'S.ContinuousUpdate, 'S.Disabled, 'S.BaseFloat]
-type instance WidgetFields 'FloatProgressType =
- BoundedFloatClass :++ ['S.Orientation, 'S.BarStyle]
-type instance WidgetFields 'FloatRangeSliderType =
+ [S.StepFloat, S.Orientation, S.ReadOut, S.ReadOutFormat, S.ContinuousUpdate, S.Disabled, S.BaseFloat]
+type instance WidgetFields FloatProgressType =
+ BoundedFloatClass :++ [S.Orientation, S.BarStyle]
+type instance WidgetFields FloatRangeSliderType =
BoundedFloatRangeClass :++
- ['S.StepFloat, 'S.Orientation, 'S.ReadOut, 'S.ReadOutFormat, 'S.ContinuousUpdate, 'S.Disabled ]
-type instance WidgetFields 'BoxType = BoxClass
-type instance WidgetFields 'GridBoxType = BoxClass
-type instance WidgetFields 'HBoxType = BoxClass
-type instance WidgetFields 'VBoxType = BoxClass
-type instance WidgetFields 'AccordionType = SelectionContainerClass
-type instance WidgetFields 'TabType = SelectionContainerClass
-type instance WidgetFields 'StackedType = SelectionContainerClass
-type instance WidgetFields 'ControllerType =
+ [S.StepFloat, S.Orientation, S.ReadOut, S.ReadOutFormat, S.ContinuousUpdate, S.Disabled ]
+type instance WidgetFields BoxType = BoxClass
+type instance WidgetFields GridBoxType = BoxClass
+type instance WidgetFields HBoxType = BoxClass
+type instance WidgetFields VBoxType = BoxClass
+type instance WidgetFields AccordionType = SelectionContainerClass
+type instance WidgetFields TabType = SelectionContainerClass
+type instance WidgetFields StackedType = SelectionContainerClass
+type instance WidgetFields ControllerType =
CoreWidgetClass :++ DOMWidgetClass :++
- ['S.Index, 'S.Name, 'S.Mapping, 'S.Connected, 'S.Timestamp, 'S.Buttons, 'S.Axes, 'S.ChangeHandler ]
-type instance WidgetFields 'ControllerAxisType = CoreWidgetClass :++ DOMWidgetClass :++ '[ 'S.FloatValue, 'S.ChangeHandler ]
-type instance WidgetFields 'ControllerButtonType = CoreWidgetClass :++ DOMWidgetClass :++ [ 'S.FloatValue, 'S.Pressed, 'S.ChangeHandler ]
-type instance WidgetFields 'LinkType = LinkClass
-type instance WidgetFields 'DirectionalLinkType = LinkClass
-type instance WidgetFields 'ButtonStyleType = StyleWidgetClass :++ ['S.ButtonColor, 'S.FontFamily, 'S.FontSize, 'S.FontStyle, 'S.FontVariant, 'S.FontWeight, 'S.TextColor, 'S.TextDecoration]
-type instance WidgetFields 'DescriptionStyleType = DescriptionStyleClass
-type instance WidgetFields 'ProgressStyleType = DescriptionStyleClass :++ '[ 'S.BarColor ]
-type instance WidgetFields 'SliderStyleType = DescriptionStyleClass :++ '[ 'S.HandleColor ]
-type instance WidgetFields 'ToggleButtonsStyleType = DescriptionStyleClass :++ ['S.ButtonWidth,'S.FontWeight]
+ [S.Index, S.Name, S.Mapping, S.Connected, S.Timestamp, S.Buttons, S.Axes, S.ChangeHandler ]
+type instance WidgetFields ControllerAxisType = CoreWidgetClass :++ DOMWidgetClass :++ '[ S.FloatValue, S.ChangeHandler ]
+type instance WidgetFields ControllerButtonType = CoreWidgetClass :++ DOMWidgetClass :++ [ S.FloatValue, S.Pressed, S.ChangeHandler ]
+type instance WidgetFields LinkType = LinkClass
+type instance WidgetFields DirectionalLinkType = LinkClass
+type instance WidgetFields ButtonStyleType = StyleWidgetClass :++ [S.ButtonColor, S.FontFamily, S.FontSize, S.FontStyle, S.FontVariant, S.FontWeight, S.TextColor, S.TextDecoration]
+type instance WidgetFields DescriptionStyleType = DescriptionStyleClass
+type instance WidgetFields ProgressStyleType = DescriptionStyleClass :++ '[ S.BarColor ]
+type instance WidgetFields SliderStyleType = DescriptionStyleClass :++ '[ S.HandleColor ]
+type instance WidgetFields ToggleButtonsStyleType = DescriptionStyleClass :++ [S.ButtonWidth,S.FontWeight]
-- Wrapper around a field's value. A dummy value is sent as an empty string to the frontend.
data AttrVal a = Dummy a
@@ -475,11 +466,10 @@ unwrap (Dummy x) = x
unwrap (Real x) = x
-- Wrapper around a field.
-data Attr (f :: Field) where
- Attr :: Typeable (FieldType f)
+data Attr f where
+ Attr :: (Typeable (FieldType f), ToKey f)
=> { _value :: AttrVal (FieldType f)
, _verify :: FieldType f -> IO (FieldType f)
- , _field :: Field
, _ro :: Bool
} -> Attr f
@@ -497,18 +487,17 @@ class ToPairs a where
toPairs :: a -> [Pair]
-- From https://stackoverflow.com/questions/68648670/duplicate-instance-declaration-using-haskell-singletons
--- TODO: Check if it can be done with something from Singletons
-instance ToPairs' (HasKey f) f => ToPairs (Attr f) where
+instance (ToKey f, ToPairs' (HasKey f) f) => ToPairs (Attr f) where
toPairs = toPairs'
-class hk ~ HasKey a => ToPairs' hk a where
+class (ToKey a, hk ~ HasKey a) => ToPairs' hk a where
toPairs' :: Attr a -> [Pair]
-instance HasKey f ~ 'False => ToPairs' 'False f where
+instance (ToKey f, HasKey f ~ 'False) => ToPairs' 'False f where
toPairs' _ = []
-instance (ToJSON (FieldType f), HasKey f ~ 'True) => ToPairs' 'True f where
- toPairs' x = [ fromString (toKey $ _field x) .= toJSON x ]
+instance (ToKey f, ToJSON (FieldType f), HasKey f ~ 'True) => ToPairs' 'True f where
+ toPairs' x = [ fromString (toKey @f) .= toJSON x ]
newtype JSONByteString = JSONByteString ByteString
deriving (Eq,Ord)
@@ -521,16 +510,16 @@ instance IsString JSONByteString where
-- | Store the value for a field, as an object parametrized by the Field. No verification is done
-- for these values.
-(=::) :: (SingI f, Typeable (FieldType f)) => Sing f -> FieldType f -> Attr f
-s =:: x = Attr { _value = Real x, _verify = return, _field = reflect s, _ro = False }
+(=::) :: forall f. (Typeable (FieldType f), ToKey f) => F f -> FieldType f -> Attr f
+F =:: x = Attr { _value = Real x, _verify = return, _ro = False }
-- | Store the value for a field, with a custom verification
-(=:.) :: (SingI f, Typeable (FieldType f)) => Sing f -> (FieldType f, FieldType f -> IO (FieldType f) ) -> Attr f
-s =:. (x,v) = Attr { _value = Real x, _verify = v, _field = reflect s, _ro = False }
+(=:.) :: forall f. (Typeable (FieldType f), ToKey f) => F f -> (FieldType f, FieldType f -> IO (FieldType f) ) -> Attr f
+F =:. (x,v) = Attr { _value = Real x, _verify = v, _ro = False }
-- | Store the value for a field, making it read only from the frontend
-(=:!) :: (SingI f, Typeable (FieldType f)) => Sing f -> FieldType f -> Attr f
-s =:! x = Attr { _value = Real x, _verify = return, _field = reflect s, _ro = True}
+(=:!) :: forall f. (Typeable (FieldType f), ToKey f) => F f -> FieldType f -> Attr f
+F =:! x = Attr { _value = Real x, _verify = return, _ro = True}
-- | If the number is in the range, return it. Otherwise raise the appropriate (over/under)flow
-- exception.
@@ -548,364 +537,358 @@ rangeSliderVerification xs@[a,b]
rangeSliderVerification _ = Ex.throw $ Ex.AssertionFailed "There should be two indices"
-- | Store a numeric value, with verification mechanism for its range.
-ranged :: (SingI f, Num (FieldType f), Ord (FieldType f), Typeable (FieldType f))
- => Sing f -> (FieldType f, FieldType f) -> AttrVal (FieldType f) -> Attr f
-ranged s range x = Attr x (rangeCheck range) (reflect s) False
+ranged :: forall f. (ToKey f, Num (FieldType f), Ord (FieldType f), Typeable (FieldType f))
+ => (FieldType f, FieldType f) -> AttrVal (FieldType f) -> Attr f
+ranged range x = Attr x (rangeCheck range) False
-- | Store a numeric value, with the invariant that it stays non-negative. The value set is set as a
-- dummy value if it's equal to zero.
-(=:+) :: (SingI f, Num (FieldType f), CustomBounded (FieldType f), Ord (FieldType f), Typeable (FieldType f))
- => Sing f -> FieldType f -> Attr f
-s =:+ val = Attr
+(=:+) :: forall f. (Num (FieldType f), CustomBounded (FieldType f), Ord (FieldType f), Typeable (FieldType f), ToKey f)
+ => F f -> FieldType f -> Attr f
+F =:+ val = Attr
((if val == 0
then Dummy
else Real)
val)
(rangeCheck (0, upperBound))
- (reflect s)
False
--- | Get a field from a singleton Adapted from: http://stackoverflow.com/a/28033250/2388535
-reflect :: forall (f :: Field). (SingI f) => Sing f -> Field
-reflect = fromSing
-
-- | A record representing a Widget class from IPython from the controls modules
defaultCoreWidget :: Rec Attr CoreWidgetClass
-defaultCoreWidget = (ViewModule =:! "@jupyter-widgets/controls")
- :& (ViewModuleVersion =:! "2.0.0")
- :& (ModelModule =:! "@jupyter-widgets/controls")
- :& (ModelModuleVersion =:! "2.0.0")
+defaultCoreWidget = (F @ViewModule =:! "@jupyter-widgets/controls")
+ :& (F @ViewModuleVersion =:! "2.0.0")
+ :& (F @ModelModule =:! "@jupyter-widgets/controls")
+ :& (F @ModelModuleVersion =:! "2.0.0")
:& RNil
-- | A record representing an object of the DOMWidget class from IPython
-defaultDOMWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> IPythonWidget 'LayoutType -> Rec Attr DOMWidgetClass
-defaultDOMWidget viewName modelName layout = (ModelName =:! modelName)
- :& (ViewName =:! viewName)
- :& (DOMClasses =:: [])
- :& (Tabbable =:: Nothing)
- :& (Tooltip =:: Nothing)
- :& (Layout =:: layout)
- :& (DisplayHandler =:: return ())
+defaultDOMWidget :: FieldType S.ViewName -> FieldType S.ModelName -> IPythonWidget LayoutType -> Rec Attr DOMWidgetClass
+defaultDOMWidget viewName modelName layout = (F @ModelName =:! modelName)
+ :& (F @ViewName =:! viewName)
+ :& (F @DOMClasses =:: [])
+ :& (F @Tabbable =:: Nothing)
+ :& (F @Tooltip =:: Nothing)
+ :& (F @Layout =:: layout)
+ :& (F @DisplayHandler =:: return ())
:& RNil
-- | A record representing an object of the DescriptionWidget class from IPython
-defaultDescriptionWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultDescriptionWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr DescriptionWidgetClass
defaultDescriptionWidget v m l d = defaultCoreWidget <+> defaultDOMWidget v m l <+> descriptionAttrs
where
- descriptionAttrs = (Description =:: "")
- :& (DescriptionAllowHtml =:: Nothing)
- :& (Style =:: d)
+ descriptionAttrs = (F @Description =:: "")
+ :& (F @DescriptionAllowHtml =:: Nothing)
+ :& (F @Style =:: d)
:& RNil
-- | A record representing a widget of the _String class from IPython
-defaultStringWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultStringWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr StringClass
defaultStringWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> strAttrs
where
- strAttrs = (StringValue =:: "")
- :& (Placeholder =:: "")
+ strAttrs = (F @StringValue =:: "")
+ :& (F @Placeholder =:: "")
:& RNil
-- | A record representing a widget of the Text class from IPython
-defaultTextWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultTextWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr TextClass
defaultTextWidget viewName modelName l d = defaultStringWidget viewName modelName l d <+> txtAttrs
where
- txtAttrs = (Disabled =:: False)
- :& (ContinuousUpdate =:: True)
- :& (SubmitHandler =:: return ())
- :& (ChangeHandler =:: return ())
+ txtAttrs = (F @Disabled =:: False)
+ :& (F @ContinuousUpdate =:: True)
+ :& (F @SubmitHandler =:: return ())
+ :& (F @ChangeHandler =:: return ())
:& RNil
-- | A record representing a widget of the _Bool class from IPython
-defaultBoolWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoolWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoolClass
defaultBoolWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> boolAttrs
where
- boolAttrs = (BoolValue =:: False)
- :& (Disabled =:: False)
- :& (ChangeHandler =:: return ())
+ boolAttrs = (F @BoolValue =:: False)
+ :& (F @Disabled =:: False)
+ :& (F @ChangeHandler =:: return ())
:& RNil
-- | A record representing a widget of the _Selection class from IPython
-defaultSelectionWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultSelectionWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr SelectionClass
defaultSelectionWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> selectionAttrs
where
- selectionAttrs = (OptionsLabels =:: [])
- :& (OptionalIndex =:: Nothing)
- :& (Disabled =:: False)
- :& (SelectionHandler =:: return ())
+ selectionAttrs = (F @OptionsLabels =:: [])
+ :& (F @OptionalIndex =:: Nothing)
+ :& (F @Disabled =:: False)
+ :& (F @SelectionHandler =:: return ())
:& RNil
-- | A record representing a widget of the _SelectionNonempty class from IPython
-defaultSelectionNonemptyWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultSelectionNonemptyWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr SelectionNonemptyClass
defaultSelectionNonemptyWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> selectionAttrs
where
- selectionAttrs = (OptionsLabels =:: [])
- :& (Index =:: 0)
- :& (Disabled =:: False)
- :& (SelectionHandler =:: return ())
+ selectionAttrs = (F @OptionsLabels =:: [])
+ :& (F @Index =:: 0)
+ :& (F @Disabled =:: False)
+ :& (F @SelectionHandler =:: return ())
:& RNil
-- | A record representing a widget of the _MultipleSelection class from IPython
-defaultMultipleSelectionWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultMultipleSelectionWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr MultipleSelectionClass
defaultMultipleSelectionWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> mulSelAttrs
where
- mulSelAttrs = (OptionsLabels =:: [])
- :& (Indices =:: [])
- :& (Disabled =:: False)
- :& (SelectionHandler =:: return ())
+ mulSelAttrs = (F @OptionsLabels =:: [])
+ :& (F @Indices =:: [])
+ :& (F @Disabled =:: False)
+ :& (F @SelectionHandler =:: return ())
:& RNil
-- | A record representing a widget of the _Int class from IPython
-defaultIntWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultIntWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr IntClass
defaultIntWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> intAttrs
where
- intAttrs = (IntValue =:: 0)
- :& (ChangeHandler =:: return ())
+ intAttrs = (F @IntValue =:: 0)
+ :& (F @ChangeHandler =:: return ())
:& RNil
-- | A record representing a widget of the _BoundedInt class from IPython
-defaultBoundedIntWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoundedIntWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoundedIntClass
defaultBoundedIntWidget viewName modelName l d = defaultIntWidget viewName modelName l d <+> boundedIntAttrs
where
- boundedIntAttrs = (MaxInt =:: 100)
- :& (MinInt =:: 0)
+ boundedIntAttrs = (F @MaxInt =:: 100)
+ :& (F @MinInt =:: 0)
:& RNil
-- | A record representing a widget of the _BoundedInt class from IPython
-defaultIntRangeWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultIntRangeWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr IntRangeClass
defaultIntRangeWidget viewName modelName l d = defaultIntWidget viewName modelName l d <+> rangeAttrs
where
- rangeAttrs = (IntPairValue =:: (25, 75))
- :& (LowerInt =:: 0)
- :& (UpperInt =:: 100)
+ rangeAttrs = (F @IntPairValue =:: (25, 75))
+ :& (F @LowerInt =:: 0)
+ :& (F @UpperInt =:: 100)
:& RNil
-- | A record representing a widget of the _BoundedIntRange class from IPython
-defaultBoundedIntRangeWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoundedIntRangeWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoundedIntRangeClass
defaultBoundedIntRangeWidget viewName modelName l d = defaultIntRangeWidget viewName modelName l d <+> boundedIntRangeAttrs
where
- boundedIntRangeAttrs = (MaxInt =:: 100)
- :& (MinInt =:: 0)
+ boundedIntRangeAttrs = (F @MaxInt =:: 100)
+ :& (F @MinInt =:: 0)
:& RNil
-- | A record representing a widget of the _Float class from IPython
-defaultFloatWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultFloatWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr FloatClass
defaultFloatWidget viewName modelName l d = defaultDescriptionWidget viewName modelName l d <+> floatAttrs
where
- floatAttrs = (FloatValue =:: 0.0)
- :& (ChangeHandler =:: return ())
+ floatAttrs = (F @FloatValue =:: 0.0)
+ :& (F @ChangeHandler =:: return ())
:& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython
-defaultBoundedFloatWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoundedFloatWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoundedFloatClass
defaultBoundedFloatWidget viewName modelName l d = defaultFloatWidget viewName modelName l d <+> boundedFloatAttrs
where
- boundedFloatAttrs = (MinFloat =:: 0)
- :& (MaxFloat =:: 100)
+ boundedFloatAttrs = (F @MinFloat =:: 0)
+ :& (F @MaxFloat =:: 100)
:& RNil
-- | A record representing a widget of the _BoundedLogFloat class from IPython
-defaultBoundedLogFloatWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoundedLogFloatWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoundedLogFloatClass
defaultBoundedLogFloatWidget viewName modelName l d = floatAttrs <+> boundedLogFloatAttrs
where
- floatAttrs = rput (FloatValue =:: 1.0) $ defaultFloatWidget viewName modelName l d
- boundedLogFloatAttrs = (MinFloat =:: 0.0)
- :& (MaxFloat =:: 4.0)
- :& (BaseFloat =:: 10.0)
+ floatAttrs = rput (F @FloatValue =:: 1.0) $ defaultFloatWidget viewName modelName l d
+ boundedLogFloatAttrs = (F @MinFloat =:: 0.0)
+ :& (F @MaxFloat =:: 4.0)
+ :& (F @BaseFloat =:: 10.0)
:& RNil
-- | A record representing a widget of the _BoundedFloat class from IPython
-defaultFloatRangeWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultFloatRangeWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr FloatRangeClass
defaultFloatRangeWidget viewName modelName l d = defaultFloatWidget viewName modelName l d <+> rangeAttrs
where
- rangeAttrs = (FloatPairValue =:: (0.0, 1.0))
+ rangeAttrs = (F @FloatPairValue =:: (0.0, 1.0))
:& RNil
-- | A record representing a widget of the _BoundedFloatRange class from IPython
-defaultBoundedFloatRangeWidget :: FieldType 'S.ViewName
- -> FieldType 'S.ModelName
- -> IPythonWidget 'LayoutType
+defaultBoundedFloatRangeWidget :: FieldType S.ViewName
+ -> FieldType S.ModelName
+ -> IPythonWidget LayoutType
-> StyleWidget
-> Rec Attr BoundedFloatRangeClass
defaultBoundedFloatRangeWidget viewName modelName l d = defaultFloatRangeWidget viewName modelName l d <+> boundedFloatRangeAttrs
where
- boundedFloatRangeAttrs = (StepFloat =:: Just 1)
- :& (MinFloat =:: 0)
- :& (MaxFloat =:: 100)
+ boundedFloatRangeAttrs = (F @StepFloat =:: Just 1)
+ :& (F @MinFloat =:: 0)
+ :& (F @MaxFloat =:: 100)
:& RNil
-- | A record representing a widget of the _Box class from IPython
-defaultBoxWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> IPythonWidget 'LayoutType -> Rec Attr BoxClass
+defaultBoxWidget :: FieldType S.ViewName -> FieldType S.ModelName -> IPythonWidget LayoutType -> Rec Attr BoxClass
defaultBoxWidget viewName modelName layout = defaultCoreWidget <+> defaultDOMWidget viewName modelName layout <+> intAttrs
where
- intAttrs = (Children =:: [])
- :& (BoxStyle =:: DefaultBox)
+ intAttrs = (F @Children =:: [])
+ :& (F @BoxStyle =:: DefaultBox)
:& RNil
-- | A record representing a widget of the _SelectionContainer class from IPython
-defaultSelectionContainerWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> IPythonWidget 'LayoutType -> Rec Attr SelectionContainerClass
+defaultSelectionContainerWidget :: FieldType S.ViewName -> FieldType S.ModelName -> IPythonWidget LayoutType -> Rec Attr SelectionContainerClass
defaultSelectionContainerWidget viewName modelName layout = defaultBoxWidget viewName modelName layout <+> selAttrs
where
- selAttrs = (Titles =:: [])
- :& (SelectedIndex =:: Nothing)
- :& (ChangeHandler =:: return ())
+ selAttrs = (F @Titles =:: [])
+ :& (F @SelectedIndex =:: Nothing)
+ :& (F @ChangeHandler =:: return ())
:& RNil
-- | A record representing a widget of the _Media class from IPython
-defaultMediaWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> IPythonWidget 'LayoutType -> Rec Attr MediaClass
+defaultMediaWidget :: FieldType S.ViewName -> FieldType S.ModelName -> IPythonWidget LayoutType -> Rec Attr MediaClass
defaultMediaWidget viewName modelName layout = defaultCoreWidget <+> defaultDOMWidget viewName modelName layout <+> mediaAttrs
where
- mediaAttrs = (BSValue =:: "")
+ mediaAttrs = (F @BSValue =:: "")
:& RNil
-defaultLinkWidget :: FieldType 'S.ModelName -> Rec Attr LinkClass
+defaultLinkWidget :: FieldType S.ModelName -> Rec Attr LinkClass
defaultLinkWidget modelName = defaultCoreWidget <+> linkAttrs
where
- linkAttrs = (ModelName =:! modelName)
- :& (Target =:: EmptyWT)
- :& (Source =:: EmptyWT)
+ linkAttrs = (F @ModelName =:! modelName)
+ :& (F @Target =:: EmptyWT)
+ :& (F @Source =:: EmptyWT)
:& RNil
-- | A record representing a widget of the Style class from IPython
-defaultStyleWidget :: FieldType 'S.ModelName -> Rec Attr StyleWidgetClass
-defaultStyleWidget modelName = (ModelName =:! modelName)
- :& (ViewName =:! "StyleView")
- :& (ViewModule =:! "@jupyter-widgets/base")
- :& (ViewModuleVersion =:! "2.0.0")
- :& (ModelModule =:! "@jupyter-widgets/controls")
- :& (ModelModuleVersion =:! "2.0.0")
+defaultStyleWidget :: FieldType S.ModelName -> Rec Attr StyleWidgetClass
+defaultStyleWidget modelName = (F @ModelName =:! modelName)
+ :& (F @ViewName =:! "StyleView")
+ :& (F @ViewModule =:! "@jupyter-widgets/base")
+ :& (F @ViewModuleVersion =:! "2.0.0")
+ :& (F @ModelModule =:! "@jupyter-widgets/controls")
+ :& (F @ModelModuleVersion =:! "2.0.0")
:& RNil
-- | A record representing a widget of the DescriptionStyle class from IPython
-defaultDescriptionStyleWidget :: FieldType 'S.ModelName -> Rec Attr DescriptionStyleClass
+defaultDescriptionStyleWidget :: FieldType S.ModelName -> Rec Attr DescriptionStyleClass
defaultDescriptionStyleWidget modelName = defaultStyleWidget modelName <+> dstyle
where
- dstyle = (DescriptionWidth =:: "")
+ dstyle = (F @DescriptionWidth =:: "")
:& RNil
-newtype WidgetState w = WidgetState { _getState :: Rec Attr (WidgetFields w) }
+data WidgetState w where
+ WidgetState :: AllToKey (WidgetFields w) => { _getState :: Rec Attr (WidgetFields w) } -> WidgetState w
-- All records with ToPair instances for their Attrs will automatically have a toJSON instance now.
-instance RecAll Attr (WidgetFields w) ToPairs => ToJSON (WidgetState w) where
+instance (AllToKey (WidgetFields w), RecAll Attr (WidgetFields w) ToPairs) => ToJSON (WidgetState w) where
toJSON record =
object
. concat
. recordToList
- . rmap (\(Compose (Dict x)) -> Const $ toPairs x) $ reifyConstraint (Proxy :: Proxy ToPairs) $ _getState
- record
+ . rmap (\(Compose (Dict x)) -> Const $ toPairs x) $ reifyConstraint (Proxy :: Proxy ToPairs) $ _getState record
-data IPythonWidget (w :: WidgetType) =
+data IPythonWidget w =
IPythonWidget
{ uuid :: UUID
, state :: IORef (WidgetState w)
}
-- | Change the value for a field, and notify the frontend about it. Doesn't work if the field is read only.
-setField :: (f ∈ WidgetFields w, IHaskellWidget (IPythonWidget w), ToPairs (Attr f))
- => IPythonWidget w -> SField f -> FieldType f -> IO ()
-setField widget sfield fval = do
- attr <- getAttr widget sfield
- when (_ro attr) $ error ("The field " ++ show (fromSing sfield) ++ " is read only")
- !newattr <- setField' widget sfield fval
+setField :: forall f w. (RElemOf f (WidgetFields w), ToKey f, IHaskellWidget (IPythonWidget w), ToPairs (Attr f))
+ => IPythonWidget w -> FieldType f -> IO ()
+setField widget fval = do
+ attr <- getAttr @f widget
+ when (_ro attr) $ error ("The field " ++ show (typeRep (Proxy @f)) ++ " is read only")
+ !newattr <- setField' @f widget fval
let pairs = toPairs newattr
unless (null pairs) $ widgetSendUpdate widget (object pairs)
-- | Change the value of a field, without notifying the frontend and without checking if is read only. For internal use.
-setField' :: (f ∈ WidgetFields w, IHaskellWidget (IPythonWidget w))
- => IPythonWidget w -> SField f -> FieldType f -> IO (Attr f)
-setField' widget sfield val = do
- attr <- getAttr widget sfield
+setField' :: forall f w. (RElemOf f (WidgetFields w), IHaskellWidget (IPythonWidget w), ToKey f)
+ => IPythonWidget w -> FieldType f -> IO (Attr f)
+setField' widget val = do
+ attr <- getAttr @f widget
newval <- _verify attr val
let newattr = attr { _value = Real newval }
- modifyIORef (state widget) (WidgetState . rput newattr . _getState)
+ modifyIORef (state widget) (\(WidgetState s) -> WidgetState (rput newattr s))
return newattr
-- | Pluck an attribute from a record
-getAttr :: (f ∈ WidgetFields w) => IPythonWidget w -> SField f -> IO (Attr f)
+getAttr :: forall f w. RElemOf f (WidgetFields w) => IPythonWidget w -> IO (Attr f)
#if MIN_VERSION_vinyl(0,9,0)
-getAttr widget _ = rget <$> _getState <$> readIORef (state widget)
+getAttr widget = rget <$> _getState <$> readIORef (state widget)
#else
-getAttr widget sfield = rget sfield <$> _getState <$> readIORef (state widget)
+getAttr widget = rget (Proxy @f) <$> _getState <$> readIORef (state widget)
#endif
-- | Get the value of a field.
-getField :: (f ∈ WidgetFields w) => IPythonWidget w -> SField f -> IO (FieldType f)
-getField widget sfield = unwrap . _value <$> getAttr widget sfield
+getField :: forall f w. RElemOf f (WidgetFields w) => IPythonWidget w -> IO (FieldType f)
+getField widget = unwrap . _value <$> getAttr @f widget
-- | Useful with toJSON and OverloadedStrings
str :: String -> String
str = id
--- | Displays on stdout the properties (and its types) of a given widget
properties :: IPythonWidget w -> IO ()
properties widget = do
- st <- readIORef $ state widget
- let convert :: Attr f -> Const (Field, TypeRep) f
- convert attr = Const (_field attr, getFieldType attr)
+ WidgetState st <- readIORef $ state widget
+ let convert :: forall f. Attr f -> Const (TypeRep, TypeRep) f
+ convert attr@(Attr {}) = Const (typeRep (Proxy @f), getFieldType attr)
renderRow (fname, ftype) = printf "%s ::: %s" (show fname) (show ftype)
- rows = map renderRow . recordToList . rmap convert $ _getState st
+ rows = map renderRow . recordToList . rmap convert $ st
mapM_ putStrLn rows
-
+
-- Helper function for widget to enforce their inability to fetch console input
noStdin :: IO a -> IO ()
noStdin action =
@@ -925,28 +908,28 @@ noStdin action =
void $ dupTo oldStdin stdInput
-- | Common function for the different trigger events
-triggerEvent :: (FieldType f ~ IO (), f ∈ WidgetFields w) => SField f -> IPythonWidget w -> IO ()
-triggerEvent sfield w = noStdin . join $ getField w sfield
+triggerEvent :: forall f w. (FieldType f ~ IO (), RElemOf f (WidgetFields w)) => IPythonWidget w -> IO ()
+triggerEvent w = noStdin . join $ getField @f w
-- | Called when the value of an attribute is changed on the front-end
-triggerChange :: ('S.ChangeHandler ∈ WidgetFields w) => IPythonWidget w -> IO ()
-triggerChange = triggerEvent ChangeHandler
+triggerChange :: RElemOf S.ChangeHandler (WidgetFields w) => IPythonWidget w -> IO ()
+triggerChange = triggerEvent @ChangeHandler
-- | Called when the button is clicked
-triggerClick :: ('S.ClickHandler ∈ WidgetFields w) => IPythonWidget w -> IO ()
-triggerClick = triggerEvent ClickHandler
+triggerClick :: RElemOf S.ClickHandler (WidgetFields w) => IPythonWidget w -> IO ()
+triggerClick = triggerEvent @ClickHandler
-- | Called when a selection is made in a selection widget
-triggerSelection :: ('S.SelectionHandler ∈ WidgetFields w) => IPythonWidget w -> IO ()
-triggerSelection = triggerEvent SelectionHandler
+triggerSelection :: RElemOf S.SelectionHandler (WidgetFields w) => IPythonWidget w -> IO ()
+triggerSelection = triggerEvent @SelectionHandler
-- | Called when the text is submited in a text widget (or combobox/password)
-triggerSubmit :: ('S.SubmitHandler ∈ WidgetFields w) => IPythonWidget w -> IO ()
-triggerSubmit = triggerEvent SubmitHandler
+triggerSubmit :: RElemOf S.SubmitHandler (WidgetFields w) => IPythonWidget w -> IO ()
+triggerSubmit = triggerEvent @SubmitHandler
-- | Called when the widget is displayed on the notebook
-triggerDisplay :: ('S.DisplayHandler ∈ WidgetFields w) => IPythonWidget w -> IO ()
-triggerDisplay = triggerEvent DisplayHandler
+triggerDisplay :: RElemOf S.DisplayHandler (WidgetFields w) => IPythonWidget w -> IO ()
+triggerDisplay = triggerEvent @DisplayHandler
-- | Every IHaskellWidget widget has the same IHaskellDisplay instance, for this
-- reason we need to use FlexibleContexts. The display implementation can still
@@ -992,12 +975,12 @@ instance FromJSON Date where
parseJSON _ = mzero
-- | Allows you to unlink a jslink
-unlink :: ('S.Source ∈ WidgetFields w, 'S.Target ∈ WidgetFields w, IHaskellWidget (IPythonWidget w))
+unlink :: (RElemOf S.Source (WidgetFields w), RElemOf S.Target (WidgetFields w), IHaskellWidget (IPythonWidget w))
=> IPythonWidget w
-> IO (IPythonWidget w)
unlink w = do
- _ <- setField' w Source EmptyWT
- _ <- setField' w Target EmptyWT
+ _ <- setField' @Source w EmptyWT
+ _ <- setField' @Target w EmptyWT
return w
data OutputMsg = OutputStream StreamType Text | OutputData Display deriving (Show)
@@ -1011,3 +994,4 @@ instance ToJSON OutputMsg where
, "data" .= toJSON d
, "metadata" .= object []
]
+