Commit e1dafd07 authored by Sumit Sahrawat's avatar Sumit Sahrawat

Fix formatting issues

- Make verify_formatting.py skip Types.hs and Common.hs
- Fix formatting issues in rest of the files
parent 112c046b
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Bool.CheckBox (
-- * The CheckBox Widget
CheckBoxWidget,
-- * The CheckBox Widget
CheckBoxWidget,
-- * Constructor
mkCheckBoxWidget,
) where
mkCheckBoxWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -41,7 +40,8 @@ mkCheckBoxWidget = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Checkbox"]
initData = object
["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Checkbox"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Bool.ToggleButton (
-- * The ToggleButton Widget
ToggleButton,
-- * The ToggleButton Widget
ToggleButton,
-- * Constructor
mkToggleButton,
) where
mkToggleButton) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -46,7 +45,8 @@ mkToggleButton = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.ToggleButton"]
initData = object
["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.ToggleButton"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......
......@@ -4,13 +4,12 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Button (
-- * The Button Widget
Button,
-- * The Button Widget
Button,
-- * Create a new button
mkButton,
-- * Click manipulation
triggerClick,
) where
triggerClick) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -20,7 +19,7 @@ import Data.Aeson
import Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -52,10 +51,7 @@ mkButton = do
let button = IPythonWidget uuid stateIO
let initData = object
[ "model_name" .= str "WidgetModel"
, "widget_class" .= str "IPython.Button"
]
let initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Button"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen button initData $ toJSON buttonState
......
......@@ -158,3 +158,6 @@ instance ToJSON ImageFormatValue where
-- | Options for selection widgets.
data SelectionOptions = OptionLabels [Text] | OptionDict [(Text, Text)]
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Image (
-- * The Image Widget
ImageWidget,
-- * The Image Widget
ImageWidget,
-- * Constructor
mkImageWidget,
) where
mkImageWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -19,7 +18,7 @@ import Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Monoid (mempty)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -47,10 +46,7 @@ mkImageWidget = do
let widget = IPythonWidget uuid stateIO
let initData = object
[ "model_name" .= str "WidgetModel"
, "widget_class" .= str "IPython.Image"
]
let initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Image"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......
......@@ -23,7 +23,7 @@ import Data.Aeson
import Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Selection.Dropdown (
-- * The Dropdown Widget
Dropdown,
-- * The Dropdown Widget
Dropdown,
-- * Constructor
mkDropdown,
) where
mkDropdown) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import qualified Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -42,7 +41,8 @@ mkDropdown = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Dropdown"]
initData = object
["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Dropdown"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......@@ -71,7 +71,8 @@ instance IHaskellWidget Dropdown where
OptionLabels _ -> do
setField' widget SSelectedLabel label
setField' widget SSelectedValue label
OptionDict ps -> case lookup label ps of
OptionDict ps ->
case lookup label ps of
Nothing -> return ()
Just value -> do
setField' widget SSelectedLabel label
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Selection.RadioButtons (
-- * The RadioButtons Widget
RadioButtons,
-- * The RadioButtons Widget
RadioButtons,
-- * Constructor
mkRadioButtons,
) where
mkRadioButtons) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import qualified Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -40,7 +39,8 @@ mkRadioButtons = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.RadioButtons"]
initData = object
["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.RadioButtons"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......@@ -69,7 +69,8 @@ instance IHaskellWidget RadioButtons where
OptionLabels _ -> do
setField' widget SSelectedLabel label
setField' widget SSelectedValue label
OptionDict ps -> case lookup label ps of
OptionDict ps ->
case lookup label ps of
Nothing -> return ()
Just value -> do
setField' widget SSelectedLabel label
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Selection.Select (
-- * The Select Widget
SelectWidget,
-- * The Select Widget
SelectWidget,
-- * Constructor
mkSelectWidget,
) where
mkSelectWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import qualified Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -69,7 +68,8 @@ instance IHaskellWidget SelectWidget where
OptionLabels _ -> do
setField' widget SSelectedLabel label
setField' widget SSelectedValue label
OptionDict ps -> case lookup label ps of
OptionDict ps ->
case lookup label ps of
Nothing -> return ()
Just value -> do
setField' widget SSelectedLabel label
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Selection.SelectMultiple (
-- * The SelectMultiple Widget
SelectMultipleWidget,
-- * The SelectMultiple Widget
SelectMultipleWidget,
-- * Constructor
mkSelectMultipleWidget,
) where
mkSelectMultipleWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -19,7 +18,7 @@ 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 Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -41,7 +40,10 @@ mkSelectMultipleWidget = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.SelectMultiple"]
initData = object
[ "model_name" .= str "WidgetModel"
, "widget_class" .= str "IPython.SelectMultiple"
]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......@@ -71,7 +73,8 @@ instance IHaskellWidget SelectMultipleWidget where
OptionLabels _ -> do
setField' widget SSelectedLabels labelList
setField' widget SSelectedValues labelList
OptionDict ps -> case sequence $ map (`lookup` ps) labelList of
OptionDict ps ->
case sequence $ map (`lookup` ps) labelList of
Nothing -> return ()
Just valueList -> do
setField' widget SSelectedLabels labelList
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.Selection.ToggleButtons (
-- * The ToggleButtons Widget
ToggleButtons,
-- * The ToggleButtons Widget
ToggleButtons,
-- * Constructor
mkToggleButtons,
) where
mkToggleButtons) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -18,7 +17,7 @@ import Data.Aeson
import qualified Data.HashMap.Strict as HM
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -45,7 +44,10 @@ mkToggleButtons = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.ToggleButtons"]
initData = object
[ "model_name" .= str "WidgetModel"
, "widget_class" .= str "IPython.ToggleButtons"
]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......@@ -74,7 +76,8 @@ instance IHaskellWidget ToggleButtons where
OptionLabels _ -> do
setField' widget SSelectedLabel label
setField' widget SSelectedValue label
OptionDict ps -> case lookup label ps of
OptionDict ps ->
case lookup label ps of
Nothing -> return ()
Just value -> do
setField' widget SSelectedLabel label
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.HTML (
-- * The HTML Widget
HTMLWidget,
-- * The HTML Widget
HTMLWidget,
-- * Constructor
mkHTMLWidget,
) where
mkHTMLWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -17,7 +16,7 @@ import Control.Monad (when, join)
import Data.Aeson
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.Latex (
-- * The Latex Widget
LatexWidget,
-- * The Latex Widget
LatexWidget,
-- * Constructor
mkLatexWidget,
) where
mkLatexWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -17,7 +16,7 @@ import Control.Monad (when, join)
import Data.Aeson
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......
......@@ -4,13 +4,12 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.Text (
-- * The Text Widget
TextWidget,
-- * The Text Widget
TextWidget,
-- * Constructor
mkTextWidget,
-- * Submit handling
triggerSubmit,
) where
triggerSubmit) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -20,7 +19,7 @@ import Data.Aeson
import qualified Data.HashMap.Strict as Map
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......
......@@ -4,11 +4,10 @@
{-# LANGUAGE TypeSynonymInstances #-}
module IHaskell.Display.Widgets.String.TextArea (
-- * The TextArea Widget
TextAreaWidget,
-- * The TextArea Widget
TextAreaWidget,
-- * Constructor
mkTextAreaWidget,
) where
mkTextAreaWidget) where
-- To keep `cabal repl` happy when running from the ihaskell repo
import Prelude
......@@ -17,7 +16,7 @@ import Control.Monad (when, join)
import Data.Aeson
import Data.IORef (newIORef)
import Data.Text (Text)
import Data.Vinyl (Rec (..), (<+>))
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -38,7 +37,8 @@ mkTextAreaWidget = do
stateIO <- newIORef widgetState
let widget = IPythonWidget uuid stateIO
initData = object ["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Textarea"]
initData = object
["model_name" .= str "WidgetModel", "widget_class" .= str "IPython.Textarea"]
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen widget initData $ toJSON widgetState
......
......@@ -329,3 +329,6 @@ str = id
instance ToJSON Natural where
toJSON 0 = String ""
toJSON n = String . pack $ show n
......@@ -51,6 +51,11 @@ for source_dir in ["src", "ipython-kernel", "ihaskell-display"]:
continue
for filename in filenames:
if "ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets" in root:
# Ignore Types.hs and Common.hs from ihaskell-widgets
# They cause issues with hindent, due to promoted types
ignored_files = ["Types.hs", "Common.hs"]
else:
# Take Haskell files, but ignore the Cabal Setup.hs
# Also ignore IHaskellPrelude.hs, it uses CPP in weird places
ignored_files = ["Setup.hs", "IHaskellPrelude.hs"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment