summaryrefslogtreecommitdiff
path: root/Reactor/Subscription.hs
blob: f496f27813f20056b6967cb969f8d66a78f1db5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{-# LANGUAGE DeriveDataTypeable #-}
module Reactor.Subscription
  ( Subscription(..)
  ) where

import Control.Applicative
import Reactor.Task
import Data.Monoid
import Data.Typeable

-- Like in real life, cancelling a subscription may not stop it from sending you stuff immediately!
newtype Subscription = Subscription { cancel :: Task () }
  deriving Typeable

instance Monoid Subscription where
  mempty = Subscription (return ())
  Subscription a `mappend` Subscription b = Subscription (a *> b)