Skip to content
Snippets Groups Projects
Commit b38ea6a3 authored by Jens Nolte's avatar Jens Nolte
Browse files

Move instances closer to their class

parent 9d6d2214
No related branches found
No related tags found
No related merge requests found
......@@ -58,9 +58,14 @@ type PullBlock = Block PullMode
-- |Cached block. Always 'yield's the latest update, so it should only be pulled when the bar is rendered.
type CachedBlock = Block CachedMode
class IsBlock a where
class IsCachableBlock a where
toCachedBlock :: a -> CachedBlock
instance IsCachableBlock PushBlock where
toCachedBlock = cachePushBlock
instance IsCachableBlock CachedBlock where
toCachedBlock = id
class IsBlockMode a where
exitBlock :: Block a
instance IsBlockMode PushMode where
......@@ -78,10 +83,6 @@ data Bar = Bar {
newBlockChan :: TChan CachedBlock
}
instance IsBlock PushBlock where
toCachedBlock = cachePushBlock
instance IsBlock CachedBlock where
toCachedBlock = id
data BarUpdateChannel = BarUpdateChannel (IO ())
type BarUpdateEvent = Event.Event
......@@ -256,7 +257,7 @@ startPersistentBlockScript path = catchP startScriptProcess handleError
updateBlock $ mkBlockOutput . pangoText $ line
lift updateBar
addBlock :: IsBlock a => a -> BarIO ()
addBlock :: IsCachableBlock a => a -> BarIO ()
addBlock block = do
newBlockChan' <- newBlockChan <$> askBar
liftIO $ atomically $ writeTChan newBlockChan' $ toCachedBlock block
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment