packages feed

jmacro-rpc 0.3.2 → 0.3.3

raw patch · 2 files changed

+16/−6 lines, 2 files

Files

Network/JMacroRPC/Panels.hs view
@@ -110,6 +110,7 @@ import qualified Text.Blaze.Html5.Attributes as H
 import Control.Applicative
 import Data.Monoid
+import Data.Semigroup (Semigroup(..))
 import Data.List(intercalate)
 import Data.String
 import Data.Aeson
@@ -142,9 +143,12 @@ -- In reality, an event is composed of the panelpaths to it's sources.
 data Event = Event [PanelPath]
 
+instance Semigroup Event where
+    (<>) (Event x) (Event y) = Event (x <> y)
+
 instance Monoid Event where
     mempty = Event []
-    mappend (Event x) (Event y) = Event (x <> y)
+    mappend = (<>)
 
 -- This isn't a real functor because fmap id isn't always id.
 -- Note that monad breaks inspectability of ids.
@@ -276,9 +280,13 @@       jsP   :: [JStat]
     }
 
+instance Semigroup PageSlice where
+    (<>) (PS h j) (PS h' j') = PS (h <> h') (j <> j')
+
+
 instance Monoid PageSlice where
     mempty = PS mempty mempty
-    mappend (PS h j) (PS h' j') = PS (h <> h') (j <> j')
+    mappend = (<>)
 
 -- | A Panel is the pair of an action to produce a PageSlice and
 -- an action to produce a list of locations with updated PageSlices.
@@ -289,9 +297,13 @@       updateP :: PState m [(PanelPath, PageSlice)]
     }
 
+
+instance Monad m => Semigroup (Panel m) where
+    (<>) (Panel d u) (Panel d' u') = Panel (liftM2 (<>) d d') (liftM2 (<>) u u')
+
 instance Monad m => Monoid (Panel m) where
     mempty = Panel (return mempty) (return mempty)
-    mappend (Panel d u) (Panel d' u') = Panel (liftM2 (<>) d d') (liftM2 (<>) u u')
+    mappend = (<>)
 
 runPanelDraw :: (Monad m, Functor m) => Map String BS.ByteString -> Set String -> Panel m -> m PageSlice
 runPanelDraw m s p = drawP p `evalStateT` startState
@@ -387,7 +399,6 @@                       )
                      (return [])
 
---TODO pure js version when both are explicitly js. Make it nontransparent.
 
 -- | Given an event, a signal, and a sink, on each firing of the event, feed the sink the current sampled value of the signal. If the Signal and Sink are both in JS, this can happen entirely on the client side.
 bindSigSink :: (Monad m, Functor m, FromJSON a, ToJSON a) => Event -> Signal typ1 a -> Sink typ2 m a -> Panel m
@@ -856,4 +867,3 @@                   ]
 
 --TODO arbitrary typeclass driven pane manipulation?
-
jmacro-rpc.cabal view
@@ -1,5 +1,5 @@ Name:                jmacro-rpc-Version:             0.3.2+Version:             0.3.3 Homepage:            http://hub.darcs.net/gershomb/jmacro License:             BSD3 License-file:        LICENSE