packages feed

threepenny-editors 0.2.0.6 → 0.2.0.7

raw patch · 5 files changed

+21/−3 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Graphics.UI.Threepenny.Editors: editorSelection :: Eq a => Behavior [(String, a)] -> EditorFactory a a
+ Graphics.UI.Threepenny.Editors.Base: editorSelection :: Eq a => Behavior [(String, a)] -> Behavior a -> Compose UI EditorDef a
+ Graphics.UI.Threepenny.Editors.Profunctor: editorSelection :: Eq a => Behavior [(String, a)] -> EditorFactory a a

Files

CHANGELOG.md view
@@ -1,3 +1,5 @@+# 0.2.0.7 (2017-05-20)+    * Added `editorSelection`. # 0.2.0.6 (2017-05-15)     * Fix the `Editable` instance for `Identity` and remove reexports. # 0.2.0.5 (2017-05-14)
src/Graphics/UI/Threepenny/Editors.hs view
@@ -16,6 +16,7 @@   , editorIdentity   , editorReadShow   , editorEnumBounded+  , editorSelection   , editorSum   , editorJust     -- ** Generic editors
src/Graphics/UI/Threepenny/Editors/Base.hs view
@@ -18,6 +18,7 @@     -- ** Editor constructors   , editorReadShow   , editorEnumBounded+  , editorSelection   , editorSum   , editorJust   -- * Reexports@@ -25,6 +26,7 @@   )where  import           Data.Functor.Compose+import           Data.Tuple import           Graphics.UI.Threepenny.Attributes import           Graphics.UI.Threepenny.Core import           Graphics.UI.Threepenny.Elements@@ -56,11 +58,11 @@ vertical, horizontal :: Layout -> Layout -> Layout vertical (Vertical xx) y = Vertical (xx ++ [y]) vertical x (Vertical yy) = Vertical (x:yy)-vertical x y = Vertical [x,y]+vertical x y             = Vertical [x,y]  horizontal (Horizontal xx) y = Horizontal (xx ++ [y]) horizontal x (Horizontal yy) = Horizontal (x : yy)-horizontal x y = Horizontal [x,y]+horizontal x y               = Horizontal [x,y]  single :: Element -> Layout single = Single@@ -169,6 +171,13 @@ instance Eq  tag  => Eq   (SumWrapper tag a) where A a _ == A b _ = a == b instance Ord tag  => Ord  (SumWrapper tag a) where compare (A a _) (A b _) = compare a b instance Show tag => Show (SumWrapper tag a) where show = show . display++-- | An editor that presents a dynamic list of options+editorSelection :: Eq a => Behavior [(String,a)] -> Behavior a -> Compose UI EditorDef a+editorSelection options selected = Compose $ do+  l <- listBox (fmap fst <$> options) ((\s o -> lookup s (fmap swap o)) <$> selected <*> options) (pure string)+  let e = filterJust $ flip lookup <$> options <@> filterJust (rumors (userSelection l))+  return $ EditorDef (tidings selected e) (single $ getElement l)  -- | An editor for union types, built from editors for its constructors. editorSum
src/Graphics/UI/Threepenny/Editors/Profunctor.hs view
@@ -31,6 +31,7 @@   , editorIdentity   , editorReadShow   , editorEnumBounded+  , editorSelection   , editorSum   , editorJust     -- ** Generic editors@@ -109,6 +110,11 @@ editorJust :: EditorFactory (Maybe a) (Maybe a) -> EditorFactory a a editorJust e = EditorFactory $ Base.editorJust (run e) +-- | An editor that presents a dynamic list of options+editorSelection :: Eq a => Behavior [(String,a)] -> EditorFactory a a+editorSelection sel = EditorFactory $ Base.editorSelection sel++-- | An editor for union types, built from editors for its constructors. editorSum   :: (Show tag, Ord tag)   => [(tag, EditorFactory b b)] -> (b -> tag) -> EditorFactory b b
threepenny-editors.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           threepenny-editors-version:        0.2.0.6+version:        0.2.0.7 synopsis:       Composable algebraic editors description:    This package provides a type class 'Editable' and combinators to                 easily put together form-like editors for algebraic datatypes.