packages feed

ihaskell-widgets 0.2.2.0 → 0.2.2.1

raw patch · 37 files changed

+87/−167 lines, 37 filesdep ~singletons

Dependency ranges changed: singletons

Files

MsgSpec.md view
@@ -8,26 +8,17 @@ ## Creating widgets  Let's say the user types in some code, and the only effect of that code is the creation of a widget.-The kernel will open a comm for the widget, and store a reference to that comm inside it. Then, to-notify the frontend about the creation of a widget, an initial state update is sent on the widget's-comm.+The kernel will open a comm for the widget, and store a reference to that comm. The comm_open message+also holds the initial state of the widget in it, which is used by the frontend to create a model for+the widget.  > The comm should be opened with a `target_name` of `"ipython.widget"`. -The initial state update message looks like this:--```json-{-    "method": "update",-    "state": { "<some/all widget properties>" }-}-```- Any *numeric* property initialized with the empty string is provided the default value by the-frontend. Some numbers need to be sent as actual numbers (when non-null), whereas some (especially-those used by sliders) need to be sent as strings.+frontend. Some numbers need to be sent as actual numbers (when non-null), whereas the ones representing+lengths in CSS units need to be sent as strings. -The initial state update must *at least* have the following fields:+The initial state must *at least* have the following fields:    - `msg_throttle` (default 3): To prevent the kernel from flooding with messages, the messages from     the widget to the kernel are throttled. If `msg_throttle` messages were sent, and all are still@@ -43,8 +34,8 @@    - Rest of the properties as required initially. -This state update is also used with fragments of the overall state to sync changes between the-frontend and the kernel.+This state is also used with fragments of the overall state to sync changes between the frontend and+the kernel.  ## Displaying widgets @@ -111,7 +102,7 @@ input widget, when an `input_request` is received.  Now, widgets cannot send `execute_request` messages. They can only send `comm_data` messages, which-means that it's not possible to fetch input through widget events.+means that it's not possible to fetch input inside widget event handlers.  --- 
ihaskell-widgets.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.2.2.0+version:             0.2.2.1  -- A short (one-line) description of the package. synopsis:            IPython standard widgets for IHaskell.@@ -104,7 +104,7 @@                      , nats -any                      , vinyl >= 0.5                      , vector -any-                     , singletons >= 0.9.0+                     , singletons >= 0.9.0 && <2.0.0.0                      , scientific -any                      , unix -any 
src/IHaskell/Display/Widgets.hs view
@@ -41,7 +41,6 @@ import           IHaskell.Display.Widgets.String.TextArea as X  import           IHaskell.Display.Widgets.Common as X-import           IHaskell.Display.Widgets.Types as X (setField, getField, properties,-                                                      triggerDisplay, triggerChange, triggerClick,-                                                      triggerSelection, triggerSubmit,-                                                      ChildWidget(..))+import           IHaskell.Display.Widgets.Types as X (setField, getField, properties, triggerDisplay,+                                                      triggerChange, triggerClick, triggerSelection,+                                                      triggerSubmit, ChildWidget(..))
src/IHaskell/Display/Widgets/Bool/CheckBox.hs view
@@ -12,12 +12,10 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import           Data.HashMap.Strict as HM import           Data.IORef (newIORef) import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Bool/ToggleButton.hs view
@@ -12,7 +12,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Bool/Valid.hs view
@@ -4,19 +4,16 @@ {-# LANGUAGE TypeSynonymInstances #-}  module IHaskell.Display.Widgets.Bool.Valid (-  -- * The Valid Widget-  ValidWidget,-  -- * Constructor-  mkValidWidget) where+-- * The Valid Widget+ValidWidget, +             -- * Constructor+             mkValidWidget) where  -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/Box/Box.hs view
@@ -12,19 +12,14 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets import           IHaskell.IPython.Message.UUID as U  import           IHaskell.Display.Widgets.Types-import           IHaskell.Display.Widgets.Common  -- | A 'Box' represents a Box widget from IPython.html.widgets. type Box = IPythonWidget BoxType
src/IHaskell/Display/Widgets/Box/FlexBox.hs view
@@ -12,11 +12,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/Box/PlaceProxy.hs view
@@ -3,21 +3,17 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeSynonymInstances #-} - module IHaskell.Display.Widgets.Box.PlaceProxy (-  -- * The PlaceProxy widget-  PlaceProxy,-  -- * Constructor-  mkPlaceProxy) where+-- * The PlaceProxy widget+PlaceProxy, +            -- * Constructor+            mkPlaceProxy) where  -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>)) import           Data.Vinyl.Lens (rput) 
src/IHaskell/Display/Widgets/Box/Proxy.hs view
@@ -5,18 +5,15 @@  module IHaskell.Display.Widgets.Box.Proxy ( -- * The Proxy widget-ProxyWidget,-     -- * Constructor-     mkProxyWidget) where+ProxyWidget, +             -- * Constructor+             mkProxyWidget) where  -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>)) import           Data.Vinyl.Lens (rput) 
src/IHaskell/Display/Widgets/Box/SelectionContainer/Accordion.hs view
@@ -12,13 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson import           Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Box/SelectionContainer/Tab.hs view
@@ -12,13 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson import           Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Button.hs view
@@ -12,7 +12,7 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join)+import           Control.Monad (when) import           Data.Aeson import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Common.hs view
@@ -4,12 +4,15 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-}+{-# LANGUAGE AutoDeriveTypeable #-}+{-# LANGUAGE DeriveDataTypeable #-}  module IHaskell.Display.Widgets.Common where  import           Data.Aeson import           Data.Aeson.Types (emptyObject) import           Data.Text (pack, Text)+import           Data.Typeable (Typeable)  import           IHaskell.Display (IHaskellWidget) import           IHaskell.Eval.Widgets (widgetSendClose)@@ -97,11 +100,11 @@ closeWidget :: IHaskellWidget w => w -> IO () closeWidget w = widgetSendClose w emptyObject -newtype StrInt = StrInt Integer-  deriving (Num, Ord, Eq, Enum)+newtype PixCount = PixCount Integer+  deriving (Num, Ord, Eq, Enum, Typeable) -instance ToJSON StrInt where-  toJSON (StrInt x) = toJSON . pack $ show x+instance ToJSON PixCount where+  toJSON (PixCount x) = toJSON . pack $ show x ++ "px"  -- | Pre-defined border styles data BorderStyleValue = NoBorder@@ -201,7 +204,7 @@ data ImageFormatValue = PNG                       | SVG                       | JPG-  deriving Eq+  deriving (Eq, Typeable)  instance Show ImageFormatValue where   show PNG = "png"
src/IHaskell/Display/Widgets/Float/BoundedFloat/BoundedFloatText.hs view
@@ -13,13 +13,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatProgress.hs view
@@ -12,13 +12,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Exception (throw, ArithException(LossOfPrecision))-import           Control.Monad (when, join) import           Data.Aeson-import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import qualified Data.Scientific as Sci-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/Float/BoundedFloat/FloatSlider.hs view
@@ -12,7 +12,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Float/BoundedFloatRange/FloatRangeSlider.hs view
@@ -13,8 +13,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Exception (throw, ArithException(LossOfPrecision))-import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Float/FloatText.hs view
@@ -12,13 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Image.hs view
@@ -12,12 +12,9 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef) import           Data.Monoid (mempty)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/Int/BoundedInt/BoundedIntText.hs view
@@ -12,13 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Int/BoundedInt/IntProgress.hs view
@@ -12,13 +12,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Exception (throw, ArithException(LossOfPrecision))-import           Control.Monad (when, join) import           Data.Aeson-import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import qualified Data.Scientific as Sci-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs view
@@ -12,7 +12,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Int/BoundedIntRange/IntRangeSlider.hs view
@@ -12,7 +12,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Int/IntText.hs view
@@ -12,13 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import qualified Data.Scientific as Sci import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Interactive.hs view
@@ -1,14 +1,11 @@-{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE GADTs #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-}+{-# LANGUAGE GADTs #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE PolyKinds #-}-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE PatternSynonyms #-}  module IHaskell.Display.Widgets.Interactive (interactive, uncurryHList, Rec(..), Argument(..)) where @@ -25,7 +22,7 @@  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 (SField, Field(..))  import           IHaskell.Display.Widgets.Box.FlexBox import           IHaskell.Display.Widgets.Bool.CheckBox@@ -44,10 +41,6 @@               a               -> WidgetConf a -newtype WrappedConstructor a =-          WrappedConstructor-            { wrappedConstructor :: IO (IPythonWidget (SuitableWidget a)) }-   type family WithTypes (ts :: [*]) (r :: *) :: * where         WithTypes '[] r = r@@ -70,8 +63,6 @@  newtype Initializer a = Initializer (IPythonWidget (SuitableWidget a) -> Argument a -> IO ()) -newtype Trigger a = Trigger (IPythonWidget (SuitableWidget a) -> IO ())-   data RequiredWidget a where         RequiredWidget ::@@ -107,11 +98,8 @@ extractEventSetter :: WidgetConf x -> EventSetter x extractEventSetter (WidgetConf wr) = EventSetter $ setEvent wr -extractTrigger :: WidgetConf x -> Trigger x-extractTrigger (WidgetConf wr) = Trigger $ trigger wr- extractInitializer :: WidgetConf x -> Initializer x-extractInitializer (WidgetConf wr) = Initializer initializer+extractInitializer WidgetConf{} = Initializer initializer  createWidget :: Constructor a -> IO (RequiredWidget a) createWidget (Constructor con) = fmap RequiredWidget con@@ -146,7 +134,6 @@       getters = rmap extractGetter rc       eventSetters = rmap extractEventSetter rc       initializers = rmap extractInitializer rc-      triggers = rmap extractTrigger rc    bx <- mkFlexBox   out <- mkOutputWidget@@ -188,14 +175,8 @@ getValue :: WrappedWidget w h f a -> IPythonWidget w -> IO a getValue (WrappedWidget _ _ field) widget = getField widget field -setValue :: WrappedWidget w h f a -> IPythonWidget w -> a -> IO ()-setValue (WrappedWidget _ _ field) widget = setField widget field- setEvent :: WrappedWidget w h f a -> IPythonWidget w -> IO () -> IO () setEvent (WrappedWidget _ h _) widget = setField widget h--trigger :: WrappedWidget w h f a -> IPythonWidget w -> IO ()-trigger (WrappedWidget _ h _) = triggerEvent h  class RecAll Attr (WidgetFields (SuitableWidget a)) ToPairs => FromWidget a where   type SuitableWidget a :: WidgetType
src/IHaskell/Display/Widgets/Output.hs view
@@ -18,12 +18,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson-import           Data.HashMap.Strict as HM import           Data.IORef (newIORef)-import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Selection/Dropdown.hs view
@@ -12,7 +12,7 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void)+import           Control.Monad (void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Selection/RadioButtons.hs view
@@ -12,12 +12,11 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void)+import           Control.Monad (when, void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Selection/SelectMultiple.hs view
@@ -12,13 +12,12 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (fmap, join, sequence, void)+import           Control.Monad (void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef) import           Data.Text (Text) import qualified Data.Vector as V-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/Selection/ToggleButtons.hs view
@@ -12,7 +12,7 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join, void)+import           Control.Monad (void) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Singletons.hs view
@@ -13,7 +13,7 @@ -- Widget properties singletons   [d|-+      data Field = ViewModule              | ViewName              | ModelModule
src/IHaskell/Display/Widgets/String/HTML.hs view
@@ -12,11 +12,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson import           Data.IORef (newIORef)-import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/String/Latex.hs view
@@ -12,11 +12,8 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson import           Data.IORef (newIORef)-import           Data.Text (Text)-import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display import           IHaskell.Eval.Widgets
src/IHaskell/Display/Widgets/String/Text.hs view
@@ -12,11 +12,10 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join)+import           Control.Monad (when) import           Data.Aeson import qualified Data.HashMap.Strict as Map import           Data.IORef (newIORef)-import           Data.Text (Text) import           Data.Vinyl (Rec(..), (<+>))  import           IHaskell.Display
src/IHaskell/Display/Widgets/String/TextArea.hs view
@@ -12,7 +12,6 @@ -- To keep `cabal repl` happy when running from the ihaskell repo import           Prelude -import           Control.Monad (when, join) import           Data.Aeson import qualified Data.HashMap.Strict as HM import           Data.IORef (newIORef)
src/IHaskell/Display/Widgets/Types.hs view
@@ -12,6 +12,8 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE AutoDeriveTypeable #-}  module IHaskell.Display.Widgets.Types where @@ -48,8 +50,8 @@ -- -- 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--- need to be sent as numbers (represented by @Integer@), whereas some need to be sent as Strings--- (@StrInt@).+-- need to be sent as numbers (represented by @Integer@), whereas some (css lengths) need to be sent+-- as Strings (@PixCount@). -- -- Child widgets are expected to be sent as strings of the form "IPY_MODEL_<uuid>", where @<uuid>@ -- represents the uuid of the widget's comm.@@ -58,19 +60,19 @@ -- look at the supplied MsgSpec.md. -- -- Widgets are not able to do console input, the reason for that can be found in the messaging--- specification-import           Control.Monad (unless, join, when, void, mapM_)+-- specification.+import           Control.Monad (unless, join, when, void) import           Control.Applicative ((<$>)) import qualified Control.Exception as Ex--import           GHC.IO.Exception+import           Data.Typeable (Typeable, TypeRep, typeOf)+import           Data.IORef (IORef, readIORef, modifyIORef)+import           Data.Text (Text, pack) import           System.IO.Error import           System.Posix.IO+import           Text.Printf (printf)  import           Data.Aeson import           Data.Aeson.Types (Pair)-import           Data.IORef (IORef, readIORef, modifyIORef)-import           Data.Text (Text, pack)  import           Data.Vinyl (Rec(..), (<+>), recordToList, reifyConstraint, rmap, Dict(..)) import           Data.Vinyl.Functor (Compose(..), Const(..))@@ -80,11 +82,13 @@ import           Data.Singletons.Prelude ((:++)) import           Data.Singletons.TH +import           GHC.IO.Exception+ import           IHaskell.Eval.Widgets (widgetSendUpdate) import           IHaskell.Display (Base64, IHaskellWidget(..)) import           IHaskell.IPython.Message.UUID -import           IHaskell.Display.Widgets.Singletons (Field, SField(..))+import           IHaskell.Display.Widgets.Singletons (Field, SField) import qualified IHaskell.Display.Widgets.Singletons as S import           IHaskell.Display.Widgets.Common @@ -140,19 +144,19 @@         FieldType S.Visible = Bool         FieldType S.CSS = [(Text, Text, Text)]         FieldType S.DOMClasses = [Text]-        FieldType S.Width = StrInt-        FieldType S.Height = StrInt-        FieldType S.Padding = StrInt-        FieldType S.Margin = StrInt+        FieldType S.Width = PixCount+        FieldType S.Height = PixCount+        FieldType S.Padding = PixCount+        FieldType S.Margin = PixCount         FieldType S.Color = Text         FieldType S.BackgroundColor = Text         FieldType S.BorderColor = Text-        FieldType S.BorderWidth = StrInt-        FieldType S.BorderRadius = StrInt+        FieldType S.BorderWidth = PixCount+        FieldType S.BorderRadius = PixCount         FieldType S.BorderStyle = BorderStyleValue         FieldType S.FontStyle = FontStyleValue         FieldType S.FontWeight = FontWeightValue-        FieldType S.FontSize = StrInt+        FieldType S.FontSize = PixCount         FieldType S.FontFamily = Text         FieldType S.Description = Text         FieldType S.ClickHandler = IO ()@@ -220,7 +224,7 @@   upperBound :: a  -- Set according to what IPython widgets use-instance CustomBounded StrInt where+instance CustomBounded PixCount where   upperBound = 10 ^ 16 - 1   lowerBound = -(10 ^ 16 - 1) @@ -312,7 +316,8 @@                                             '[S.Orientation, S.ShowRange, S.ReadOut, S.SliderColor]         WidgetFields BoxType = BoxClass         WidgetFields ProxyType = WidgetClass :++ '[S.Child]-        WidgetFields PlaceProxyType = WidgetFields ProxyType :++ '[S.Selector]+        WidgetFields PlaceProxyType =+                                    WidgetFields ProxyType :++ '[S.Selector]         WidgetFields FlexBoxType =                                  BoxClass :++ '[S.Orientation, S.Flex, S.Pack, S.Align]         WidgetFields AccordionType = SelectionContainerClass@@ -327,13 +332,16 @@ unwrap (Real x) = x  -- Wrapper around a field.-data Attr (f :: Field) =-       Attr-         { _value :: AttrVal (FieldType f)-         , _verify :: FieldType f -> IO (FieldType f)-         , _field :: Field-         }+data Attr (f :: Field) where+  Attr :: Typeable (FieldType f)+       => { _value :: AttrVal (FieldType f)+          , _verify :: FieldType f -> IO (FieldType f)+          , _field :: Field+          } -> Attr f +getFieldType :: Attr f -> TypeRep+getFieldType Attr { _value = attrval } = typeOf $ unwrap attrval+ instance ToJSON (FieldType f) => ToJSON (Attr f) where   toJSON attr =     case _value attr of@@ -581,7 +589,7 @@  -- | Store the value for a field, as an object parametrized by the Field. No verification is done -- for these values.-(=::) :: SingI f => Sing f -> FieldType f -> Attr f+(=::) :: (SingI f, Typeable (FieldType f)) => Sing f -> FieldType f -> Attr f s =:: x = Attr { _value = Real x, _verify = return, _field = reflect s }  -- | If the number is in the range, return it. Otherwise raise the appropriate (over/under)flow@@ -594,13 +602,13 @@   | otherwise = error "The impossible happened in IHaskell.Display.Widgets.Types.rangeCheck"  -- | Store a numeric value, with verification mechanism for its range.-ranged :: (SingI f, Num (FieldType f), Ord (FieldType f))+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)  -- | 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))+(=:+) :: (SingI f, Num (FieldType f), CustomBounded (FieldType f), Ord (FieldType f), Typeable (FieldType f))       => Sing f -> FieldType f -> Attr f s =:+ val = Attr               ((if val == 0@@ -837,9 +845,12 @@ properties :: IPythonWidget w -> IO () properties widget = do   st <- readIORef $ state widget-  let convert :: Attr f -> Const Field f-      convert attr = Const { getConst = _field attr }-  mapM_ print $ recordToList . rmap convert . _getState $ st+  let convert :: Attr f -> Const (Field, TypeRep) f+      convert attr = Const (_field attr, getFieldType attr)++      renderRow (fname, ftype) = printf "%s ::: %s" (show fname) (show ftype)+      rows = map renderRow . recordToList . rmap convert $ _getState st+  mapM_ putStrLn rows  -- Helper function for widget to enforce their inability to fetch console input noStdin :: IO a -> IO ()