threepenny-editors 0.5.6 → 0.5.6.1
raw patch · 4 files changed
+90/−59 lines, 4 filesdep +semigroupsdep ~containers
Dependencies added: semigroups
Dependency ranges changed: containers
Files
- CHANGELOG.md +5/−0
- src/Graphics/UI/Threepenny/Editors.hs +7/−6
- src/Graphics/UI/Threepenny/Editors/Layout.hs +30/−12
- threepenny-editors.cabal +48/−41
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.5.6.1 (2018-10-07)+ * Semigroup => Monoid+# 0.5.6 (2017-10-29)+ * Add editors for collections+ * Add an editor for `Text` # 0.5.5 (2017-09-03) * Dropped `Default` constraint requisite and `data-default` dependency. * As a result, `editorGenericSimple` is replaced with `editorGeneric`.
src/Graphics/UI/Threepenny/Editors.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -12,6 +11,7 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableSuperClasses #-}@@ -124,6 +124,7 @@ import Data.Functor.Compose import Data.Functor.Identity import Data.HasEmpty+import Data.Kind import Data.Maybe import qualified Data.Sequence as Seq import Data.Text (Text)@@ -391,18 +392,18 @@ go _ SNil = Nil2 go f SCons = bimap EditorWidgetFor id (dimapE (unI . hd . f) id editor) :** go (tl . f) sList +{----------------------------------------------+ Generic derivations for Applicative Editables+-----------------------------------------------}+ -- A bifunctorial version of NP, used to sequence the applicative effects-data NP2 :: (k -> *) -> (k -> k -> *) -> [k] -> * where+data NP2 :: (k -> *) -> (* -> k -> *) -> [k] -> * where Nil2 :: NP2 ann f '[] (:**) :: f (ann x) x -> NP2 ann f xs -> NP2 ann f (x ': xs) sequence_NP2 :: Biapplicative f => NP2 w f xs -> f (NP w xs) (NP I xs) sequence_NP2 Nil2 = bipure Nil Nil sequence_NP2 (x :** xs) = bipure (:*) (\x xx -> I x :* xx) <<*>> x <<*>> sequence_NP2 xs--{----------------------------------------------- Generic derivations for Applicative Editables------------------------------------------------} constructorEditorFor :: (All Editable xs, All HasEmpty xs)
src/Graphics/UI/Threepenny/Editors/Layout.hs view
@@ -33,21 +33,30 @@ , type (-*-)(..) ) where +import Control.Monad import Data.Biapplicative import Data.Bifoldable import Data.HasEmpty-import Data.Foldable (length)+import Data.Foldable (Foldable(foldMap))+import Data.Function+import Data.Functor+import Data.List import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe-import Data.Monoid+import Data.Monoid (Monoid(..))+import Data.Ord+import Data.Semigroup import Data.Sequence (Seq) import qualified Data.Sequence as Seq+import Data.Tuple import Generics.SOP.TH import GHC.Exts (IsList (..)) import Graphics.UI.Threepenny.Core as UI hiding (empty) import Graphics.UI.Threepenny.Elements import Graphics.UI.Threepenny.Widgets+import Text.Show+import Prelude(Num(..), Int, String, otherwise) -- | Closely related to 'Widget', this class represents types that can be rendered to an 'Element', either directly or via 'Layout'. class Renderable w where@@ -124,9 +133,12 @@ vertical :: Renderable w => w -> Vertical vertical = Vertical . getLayout +instance Semigroup Vertical where+ Vertical a <> Vertical b = Vertical $ above a b+ instance Monoid Vertical where mempty = Vertical HasEmpty- mappend (Vertical a) (Vertical b)= Vertical $ above a b+ mappend = (<>) instance Renderable Vertical where getLayout = getVertical@@ -137,9 +149,12 @@ horizontal :: Renderable w => w -> Horizontal horizontal = Horizontal . getLayout +instance Semigroup Horizontal where+ Horizontal a <> Horizontal b = Horizontal $ beside a b+ instance Monoid Horizontal where mempty = Horizontal HasEmpty- mappend (Horizontal a) (Horizontal b)= Horizontal $ beside a b+ mappend = (<>) instance Renderable Horizontal where getLayout = getHorizontal@@ -178,16 +193,19 @@ instance Monoid Columns where mempty = Columns (-1,-1) mempty- mappend (Next a) (Columns (r,c) g) = let xy = (r+1, max 0 c) in Columns xy (Map.insert xy a g)- mappend (Break a) (Columns (_,c) g) = let xy = (0, c + 1) in Columns xy (Map.insert xy a g)+ mappend = (<>)++instance Semigroup Columns where+ Next a <> Columns (r,c) g = let xy = (r+1, max 0 c) in Columns xy (Map.insert xy a g)+ Break a <> Columns (_,c) g = let xy = (0, c + 1) in Columns xy (Map.insert xy a g) -- merging two columns should not ever happen, but if it does we will merge the columns and Break into a new one- mappend (Columns (r,c) g) (Columns (r',_) g') = Columns (r+r'+1, -1) (Map.union g (Map.mapKeys (\(x,y) -> (x+r+1,y+c+1)) g'))- mappend c@Columns{} other = mappend other c+ Columns (r,c) g <> Columns (r',_) g' = Columns (r+r'+1, -1) (Map.union g (Map.mapKeys (\(x,y) -> (x+r+1,y+c+1)) g'))+ c@Columns{} <> other = mappend other c -- Next and Break merges should not arise in practice either- mappend (Next a) (Next b) = Columns ( 1,0) (Map.fromList [((0,0),a), ((1,0),b)])- mappend (Next a) (Break b) = Columns ( 0,1) (Map.fromList [((0,0),a), ((0,1),b)])- mappend (Break a) (Break b) = mappend (Next a) (Break b)- mappend (Break a) (Next b) = mappend (Next a) (Next b)+ Next a <> Next b = Columns ( 1,0) (Map.fromList [((0,0),a), ((1,0),b)])+ Next a <> Break b = Columns ( 0,1) (Map.fromList [((0,0),a), ((0,1),b)])+ Break a <> Break b = mappend (Next a) (Break b)+ Break a <> Next b = mappend (Next a) (Next b) -- | Type level Horizontal layouts data a |*| b = a :|*| b
threepenny-editors.cabal view
@@ -1,9 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.28.2. -- -- see: https://github.com/sol/hpack+--+-- hash: fe4c4326de8d1b9b98aa181046d238944a1367f74a0606e8d110ecee2dded374 name: threepenny-editors-version: 0.5.6+version: 0.5.6.1 synopsis: Composable algebraic editors description: This package provides a type class 'Editable' and combinators to easily put together form-like editors for algebraic datatypes.@@ -21,7 +23,6 @@ license-file: LICENSE build-type: Simple cabal-version: >= 1.10- extra-source-files: CHANGELOG.md README.md@@ -32,18 +33,6 @@ default: False library- hs-source-dirs:- src- ghc-options: -Wall -Wno-name-shadowing- build-depends:- base >= 4.7 && < 5- , bifunctors- , containers- , generics-sop- , profunctors- , threepenny-gui > 0.7- , casing- , text exposed-modules: Data.HasEmpty Graphics.UI.Threepenny.Editors@@ -53,6 +42,19 @@ Graphics.UI.Threepenny.Editors.Validation other-modules: Paths_threepenny_editors+ hs-source-dirs:+ src+ ghc-options: -Wall -Wno-name-shadowing+ build-depends:+ base >=4.7 && <5+ , bifunctors+ , casing+ , containers >=0.5.9+ , generics-sop+ , profunctors+ , semigroups+ , text+ , threepenny-gui >0.7 default-language: Haskell2010 executable crud@@ -61,18 +63,19 @@ examples ghc-options: -Wall -Wno-name-shadowing -main-is CRUD build-depends:- base >= 4.7 && < 5+ base >=4.7 && <5 , bifunctors- , containers+ , casing+ , containers >=0.5.9 , generics-sop , profunctors- , threepenny-gui > 0.7- , casing+ , semigroups , text+ , threepenny-gui >0.7 if flag(buildExamples) build-depends:- threepenny-editors- , containers+ containers+ , threepenny-editors else buildable: False default-language: Haskell2010@@ -83,18 +86,19 @@ examples ghc-options: -Wall -Wno-name-shadowing -main-is CRUD2 build-depends:- base >= 4.7 && < 5+ base >=4.7 && <5 , bifunctors- , containers+ , casing+ , containers >=0.5.9 , generics-sop , profunctors- , threepenny-gui > 0.7- , casing+ , semigroups , text+ , threepenny-gui >0.7 if flag(buildExamples) build-depends:- threepenny-editors- , containers+ containers+ , threepenny-editors else buildable: False default-language: Haskell2010@@ -105,18 +109,19 @@ examples ghc-options: -Wall -Wno-name-shadowing -main-is Parser build-depends:- base >= 4.7 && < 5+ base >=4.7 && <5 , bifunctors- , containers+ , casing+ , containers >=0.5.9 , generics-sop , profunctors- , threepenny-gui > 0.7- , casing+ , semigroups , text+ , threepenny-gui >0.7 if flag(buildExamples) build-depends:- threepenny-editors- , haskell-src-exts+ haskell-src-exts+ , threepenny-editors else buildable: False default-language: Haskell2010@@ -127,14 +132,15 @@ examples ghc-options: -Wall -Wno-name-shadowing -main-is Person build-depends:- base >= 4.7 && < 5+ base >=4.7 && <5 , bifunctors- , containers+ , casing+ , containers >=0.5.9 , generics-sop , profunctors- , threepenny-gui > 0.7- , casing+ , semigroups , text+ , threepenny-gui >0.7 if flag(buildExamples) build-depends: threepenny-editors@@ -148,14 +154,15 @@ examples ghc-options: -Wall -Wno-name-shadowing -main-is Person2 build-depends:- base >= 4.7 && < 5+ base >=4.7 && <5 , bifunctors- , containers+ , casing+ , containers >=0.5.9 , generics-sop , profunctors- , threepenny-gui > 0.7- , casing+ , semigroups , text+ , threepenny-gui >0.7 if flag(buildExamples) build-depends: threepenny-editors