Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
26903b1e
Commit
26903b1e
authored
Jul 03, 2015
by
Sumit Sahrawat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using Numeric.Natural
parent
05e33cbf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
27 deletions
+28
-27
ihaskell-widgets.cabal
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
+1
-0
Common.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+0
-7
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+27
-20
No files found.
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
View file @
26903b1e
...
@@ -78,6 +78,7 @@ library
...
@@ -78,6 +78,7 @@ library
, unordered-containers >= 0.2.5.1
, unordered-containers >= 0.2.5.1
-- TODO: Need to check versions
-- TODO: Need to check versions
, nats -any
, vinyl -any
, vinyl -any
, singletons -any
, singletons -any
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
View file @
26903b1e
...
@@ -163,10 +163,3 @@ instance Show ImageFormatValue where
...
@@ -163,10 +163,3 @@ instance Show ImageFormatValue where
instance
ToJSON
ImageFormatValue
where
instance
ToJSON
ImageFormatValue
where
toJSON
=
toJSON
.
pack
.
show
toJSON
=
toJSON
.
pack
.
show
newtype
PosInt
=
PosInt
{
unwrap
::
Int
}
instance
ToJSON
PosInt
where
toJSON
(
PosInt
x
)
|
x
>
0
=
String
.
pack
$
show
x
|
otherwise
=
""
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
26903b1e
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE BangPatterns #-}
module
IHaskell.Display.Widgets.Types
where
module
IHaskell.Display.Widgets.Types
where
import
Control.Monad
(
when
)
import
Control.Monad
(
when
)
...
@@ -30,6 +31,8 @@ import qualified Data.Vinyl.TypeLevel as TL
...
@@ -30,6 +31,8 @@ import qualified Data.Vinyl.TypeLevel as TL
import
Data.Singletons.TH
import
Data.Singletons.TH
import
Numeric.Natural
import
IHaskell.Eval.Widgets
(
widgetSendUpdate
)
import
IHaskell.Eval.Widgets
(
widgetSendUpdate
)
import
IHaskell.Display
(
Base64
,
IHaskellWidget
(
..
))
import
IHaskell.Display
(
Base64
,
IHaskellWidget
(
..
))
import
IHaskell.IPython.Message.UUID
import
IHaskell.IPython.Message.UUID
...
@@ -51,25 +54,25 @@ type family FieldType (f :: Field) :: * where
...
@@ -51,25 +54,25 @@ type family FieldType (f :: Field) :: * where
FieldType
ModelName
=
Text
FieldType
ModelName
=
Text
FieldType
ViewModule
=
Text
FieldType
ViewModule
=
Text
FieldType
ViewName
=
Text
FieldType
ViewName
=
Text
FieldType
MsgThrottle
=
PosInt
FieldType
MsgThrottle
=
Natural
FieldType
Version
=
PosInt
FieldType
Version
=
Natural
FieldType
OnDisplayed
=
IO
()
FieldType
OnDisplayed
=
IO
()
FieldType
Visible
=
Bool
FieldType
Visible
=
Bool
FieldType
CSS
=
[(
Text
,
Text
,
Text
)]
FieldType
CSS
=
[(
Text
,
Text
,
Text
)]
FieldType
DOMClasses
=
[
Text
]
FieldType
DOMClasses
=
[
Text
]
FieldType
Width
=
PosInt
FieldType
Width
=
Natural
FieldType
Height
=
PosInt
FieldType
Height
=
Natural
FieldType
Padding
=
PosInt
FieldType
Padding
=
Natural
FieldType
Margin
=
PosInt
FieldType
Margin
=
Natural
FieldType
Color
=
Text
FieldType
Color
=
Text
FieldType
BackgroundColor
=
Text
FieldType
BackgroundColor
=
Text
FieldType
BorderColor
=
Text
FieldType
BorderColor
=
Text
FieldType
BorderWidth
=
PosInt
FieldType
BorderWidth
=
Natural
FieldType
BorderRadius
=
PosInt
FieldType
BorderRadius
=
Natural
FieldType
BorderStyle
=
BorderStyleValue
FieldType
BorderStyle
=
BorderStyleValue
FieldType
FontStyle
=
FontStyleValue
FieldType
FontStyle
=
FontStyleValue
FieldType
FontWeight
=
FontWeightValue
FieldType
FontWeight
=
FontWeightValue
FieldType
FontSize
=
PosInt
FieldType
FontSize
=
Natural
FieldType
FontFamily
=
Text
FieldType
FontFamily
=
Text
FieldType
Description
=
Text
FieldType
Description
=
Text
FieldType
ClickHandler
=
IO
()
FieldType
ClickHandler
=
IO
()
...
@@ -150,8 +153,8 @@ defaultWidget viewName = (SModelModule =:: "")
...
@@ -150,8 +153,8 @@ defaultWidget viewName = (SModelModule =:: "")
:&
(
SModelName
=::
"WidgetModel"
)
:&
(
SModelName
=::
"WidgetModel"
)
:&
(
SViewModule
=::
""
)
:&
(
SViewModule
=::
""
)
:&
(
SViewName
=::
viewName
)
:&
(
SViewName
=::
viewName
)
:&
(
SMsgThrottle
=::
PosInt
3
)
:&
(
SMsgThrottle
=::
3
)
:&
(
SVersion
=::
PosInt
0
)
:&
(
SVersion
=::
0
)
:&
(
SOnDisplayed
=::
return
()
)
:&
(
SOnDisplayed
=::
return
()
)
:&
RNil
:&
RNil
...
@@ -160,19 +163,19 @@ defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs
...
@@ -160,19 +163,19 @@ defaultDOMWidget viewName = defaultWidget viewName <+> domAttrs
where
domAttrs
=
(
SVisible
=::
True
)
where
domAttrs
=
(
SVisible
=::
True
)
:&
(
SCSS
=::
[]
)
:&
(
SCSS
=::
[]
)
:&
(
SDOMClasses
=::
[]
)
:&
(
SDOMClasses
=::
[]
)
:&
(
SWidth
=::
PosInt
0
)
:&
(
SWidth
=::
0
)
:&
(
SHeight
=::
PosInt
0
)
:&
(
SHeight
=::
0
)
:&
(
SPadding
=::
PosInt
0
)
:&
(
SPadding
=::
0
)
:&
(
SMargin
=::
PosInt
0
)
:&
(
SMargin
=::
0
)
:&
(
SColor
=::
""
)
:&
(
SColor
=::
""
)
:&
(
SBackgroundColor
=::
""
)
:&
(
SBackgroundColor
=::
""
)
:&
(
SBorderColor
=::
""
)
:&
(
SBorderColor
=::
""
)
:&
(
SBorderWidth
=::
PosInt
0
)
:&
(
SBorderWidth
=::
0
)
:&
(
SBorderRadius
=::
PosInt
0
)
:&
(
SBorderRadius
=::
0
)
:&
(
SBorderStyle
=::
DefaultBorder
)
:&
(
SBorderStyle
=::
DefaultBorder
)
:&
(
SFontStyle
=::
DefaultFont
)
:&
(
SFontStyle
=::
DefaultFont
)
:&
(
SFontWeight
=::
DefaultWeight
)
:&
(
SFontWeight
=::
DefaultWeight
)
:&
(
SFontSize
=::
PosInt
0
)
:&
(
SFontSize
=::
0
)
:&
(
SFontFamily
=::
""
)
:&
(
SFontFamily
=::
""
)
:&
RNil
:&
RNil
...
@@ -212,9 +215,9 @@ setField widget (sfield :: SField f) fval = do
...
@@ -212,9 +215,9 @@ setField widget (sfield :: SField f) fval = do
let
pairs
=
toPairs
(
Attr
fval
::
Attr
f
)
let
pairs
=
toPairs
(
Attr
fval
::
Attr
f
)
when
(
not
.
null
$
pairs
)
$
widgetSendUpdate
widget
(
object
pairs
)
when
(
not
.
null
$
pairs
)
$
widgetSendUpdate
widget
(
object
pairs
)
-- | Change the value of a field, without notifying the frontend. For internal use.
-- | Change the value of a field, without notifying the frontend. For internal use.
Uses BangPattern.
setField'
::
(
f
∈
WidgetFields
w
,
IHaskellWidget
(
Widget
w
),
SingI
f
)
=>
Widget
w
->
SField
f
->
FieldType
f
->
IO
()
setField'
::
(
f
∈
WidgetFields
w
,
IHaskellWidget
(
Widget
w
),
SingI
f
)
=>
Widget
w
->
SField
f
->
FieldType
f
->
IO
()
setField'
widget
(
sfield
::
SField
f
)
fval
=
modifyIORef
(
state
widget
)
(
WidgetState
.
rput
(
sfield
=::
fval
)
.
_getState
)
setField'
widget
(
sfield
::
SField
f
)
!
fval
=
modifyIORef
(
state
widget
)
(
WidgetState
.
rput
(
sfield
=::
fval
)
.
_getState
)
-- | Get the value of a field.
-- | Get the value of a field.
getField
::
(
f
∈
WidgetFields
w
)
=>
Widget
w
->
SField
f
->
IO
(
FieldType
f
)
getField
::
(
f
∈
WidgetFields
w
)
=>
Widget
w
->
SField
f
->
IO
(
FieldType
f
)
...
@@ -223,3 +226,7 @@ getField widget sfield = _unAttr <$> rget sfield <$> _getState <$> readIORef (st
...
@@ -223,3 +226,7 @@ getField widget sfield = _unAttr <$> rget sfield <$> _getState <$> readIORef (st
-- | Useful with toJSON, and OverloadedStrings
-- | Useful with toJSON, and OverloadedStrings
str
::
String
->
String
str
::
String
->
String
str
=
id
str
=
id
instance
ToJSON
Natural
where
toJSON
0
=
String
""
toJSON
n
=
String
.
pack
$
show
n
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment